Files
AuthMicroservice/app/utils/bcrypt_utils.py
roma-dxunvrs 27466a255f Demo
2025-11-30 12:38:46 +03:00

17 lines
376 B
Python

import bcrypt
def hash_password(
password: str
) -> bytes:
salt = bcrypt.gensalt()
pwd_bytes: bytes = password.encode()
return bcrypt.hashpw(pwd_bytes, salt)
def validate_password(
password: str,
hashed_password: bytes
) -> bool:
return bcrypt.checkpw(
password=password.encode(),
hashed_password=hashed_password
)