keepme-backend / src /utils /_bcrypt_util.py
ramanjitsingh1368's picture
Refactor Dockerfile and clean up unused schemas; update Redis client initialization and environment configuration
a3aa6c1
raw
history blame contribute delete
535 Bytes
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)