def db_value(self, value): return value if value is None else u( hashpw( b(value), gensalt(self.bcrypt_iterations) ) )
def check_password(self, password): password = b(password) pw_hash = b(self) hashed = b(hashpw(password, pw_hash)) log.debug("Password hashed=%r self=%r", hashed, self) return hashed == pw_hash