forked from mtusi2026/mtusi2026lab3
16 lines
409 B
Python
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
|