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)