Spaces:
Runtime error
Runtime error
File size: 441 Bytes
8673167 1296cbb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | import bcrypt
def _hash_password(plain: str) -> str:
return bcrypt.hashpw(plain.encode(), bcrypt.gensalt()).decode()
def _is_hashed(stored: str) -> bool:
return stored.startswith(("$2b$", "$2a$"))
def _verify_password(plain: str, stored: str) -> bool:
if _is_hashed(stored):
try:
return bcrypt.checkpw(plain.encode(), stored.encode())
except Exception:
return False
return False
|