"""Passwort-Hashing mit Argon2id.""" from __future__ import annotations from argon2 import PasswordHasher from argon2.exceptions import InvalidHashError, VerifyMismatchError _hasher = PasswordHasher() def hash_password(password: str) -> str: return _hasher.hash(password) def verify_password(password_hash: str, password: str) -> bool: try: _hasher.verify(password_hash, password) except (VerifyMismatchError, InvalidHashError): return False return True