To hash a password in Python, it is recommended to use a reputable library such as bcrypt or argon2. Here is an example using bcrypt:
main.py360 chars14 lines
In the above example, we first generate a salt using gensalt() and then use it to hash the password using hashpw(). To verify a password, we simply attempt to hash the provided password using the same salt, and compare the result to the original hashed password using checkpw().
gistlibby LogSnag