Spaces:
Runtime error
Runtime error
File size: 535 Bytes
4f26fae a3aa6c1 4f26fae a3aa6c1 4f26fae |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
import bcrypt
class BcryptUtil:
@staticmethod
def hash_password(password: str) -> str:
salt = bcrypt.gensalt()
hashed_password = bcrypt.hashpw(password.encode("utf-8"), salt)
return hashed_password.decode("utf-8")
@staticmethod
def compare_password(stored_password: str, provided_password: str) -> bool:
stored_password = stored_password.encode("utf-8")
provided_password = provided_password.encode("utf-8")
return bcrypt.checkpw(provided_password, stored_password)
|