Spaces:
Runtime error
Runtime error
File size: 539 Bytes
1771391 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
"""
Utility functions for CRUD operations.
"""
import bcrypt
def hash_password(password: str) -> str:
"""Hashes a password using bcrypt."""
return bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt()).decode('utf-8')
def verify_password(plain_password: str, hashed_password_str: str) -> bool:
"""Verifies a plain password against a hashed password."""
if not plain_password or not hashed_password_str:
return False
return bcrypt.checkpw(plain_password.encode('utf-8'), hashed_password_str.encode('utf-8')) |