Spaces:
No application file
No application file
| """ | |
| Security utilities for password hashing and verification. | |
| Uses bcrypt for secure password hashing. | |
| """ | |
| from passlib.context import CryptContext | |
| # Bcrypt context for password hashing | |
| pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto") | |
| def hash_password(password: str) -> str: | |
| """ | |
| Hash a plaintext password using bcrypt. | |
| Args: | |
| password: Plaintext password to hash | |
| Returns: | |
| Hashed password string | |
| """ | |
| return pwd_context.hash(password) | |
| def verify_password(plain_password: str, hashed_password: str) -> bool: | |
| """ | |
| Verify a plaintext password against a hashed password. | |
| Args: | |
| plain_password: Plaintext password to verify | |
| hashed_password: Stored hashed password | |
| Returns: | |
| True if password matches, False otherwise | |
| """ | |
| return pwd_context.verify(plain_password, hashed_password) | |