"""Password hashing utilities using bcrypt directly.""" import asyncio import bcrypt def hash_password(password: str) -> str: return bcrypt.hashpw(password.encode("utf-8"), bcrypt.gensalt()).decode("utf-8") def verify_password(plain_password: str, hashed_password: str) -> bool: return bcrypt.checkpw(plain_password.encode("utf-8"), hashed_password.encode("utf-8")) async def hash_password_async(password: str) -> str: return await asyncio.to_thread(hash_password, password) async def verify_password_async(plain_password: str, hashed_password: str) -> bool: return await asyncio.to_thread(verify_password, plain_password, hashed_password)