I've two rest endpoints, one that registers an user and the second that lets that user login. This is the code that I'm using to hash the user's password and store the hashed password in the database,
from passlib.hash import pbkdf2_sha256
def _get_hashed_password(self, password):
return pbkdf2_sha256.encrypt(password, rounds=200000, salt_size=16)
Now on the login endpoint I use this code to verify the hashed password,
password = data['password']
hash = pbkdf2_sha256.encrypt(password, rounds=200000, salt_size=16)
pbkdf2_sha256.verify(user.hashed_password, hash)
This method fails and clearly because the two passwords are different,
$pbkdf2-sha256$200000$ai0FoDTG2BuDkDKGEIJQKg$Ik06dr61.2rRMDwZCZMdVq.zMe5887.ksDxvmSXFRwE
$pbkdf2-sha256$200000$pHTuHYNwLoXQeu8dI0QoxQ$2z4cZl9Njz9X/bxNtWCZzzeplWO.jTZA2v5lvcmgFE8
I'm wondering how can I get this to work?