samedi 23 juillet 2016

Comparing password to encrypted passwork using bcryt in Django

I am trying to compare a user entered password field to a password that has been encrypted. I have looked at the documentation and have not been able to find what I have been looking for. I encrypt the password using

pw_bytes = password.encode('utf-8')
hashed = bcrypt.hashpw(pw_bytes, bcrypt.gensalt())

If I re-encrypt the password, it gives me a different hash. How do I deencrypt the password from my db, or re-encrypt the password the user provided so that they match?

Aucun commentaire:

Enregistrer un commentaire