from __future__ import annotations import secrets import bcrypt def hash_password(password: str) -> str: return bcrypt.hashpw(password.encode("utf-8"), bcrypt.gensalt()).decode() def verify_password(password: str, password_hash: str) -> bool: return bcrypt.checkpw(password.encode("utf-8"), password_hash.encode()) def generate_token() -> str: return secrets.token_urlsafe(32)