Files
mtusi2026lab2/app/auth/passwords.py
T
vozzhin 1dd701be2b
Skeleton contracts / contracts (pull_request) Canceled after 0s
ЛР 2: мессенджер на PostgreSQL и сессии в Redis
2026-10-23 12:16:56 +03:00

16 lines
409 B
Python

from argon2 import PasswordHasher
from argon2.exceptions import VerificationError, VerifyMismatchError
_hasher = PasswordHasher()
def hash_password(password: str) -> str:
return _hasher.hash(password)
def password_matches(stored_hash: str, password: str) -> bool:
try:
return _hasher.verify(stored_hash, password)
except (VerifyMismatchError, VerificationError):
return False