Error: Invalid salt
adsahay opened this issue · comments
I'm using this extension for simple password encryption and matching. I use generate_password_hash
and save the encrypted password in the database when creating a new user.
When trying to login this user, check_password_hash(password, db_user_password)
throws an Invalid salt
exception. I don't know how to debug this. Any help?
Could there be an encoding issue somewhere? I don't know a thing about encryption except generating and matching hashes, help would be appreciated.
Sorry this is a non-issue, just needed to swap the order of parameters of check_password_hash. Stupid me.
Hi,
You may need to encode the candidate password, i.e. the password to be checked, before running check_password_hash if you're using unicode.
Here's an example: https://github.com/maxcountryman/flask-bcrypt/blob/master/test_bcrypt.py#L40
Basically what you want to do is password.encode('utf-8')
which will produce '\xe2\x98\x83'
.
Hope that helps!
Okay, good to know. 🍰