13 lines
341 B
Python
13 lines
341 B
Python
|
|
"""
|
||
|
|
Password hashing and validation utilities.
|
||
|
|
"""
|
||
|
|
import bcrypt
|
||
|
|
|
||
|
|
|
||
|
|
def hash_password(password: str) -> str:
|
||
|
|
return bcrypt.hashpw(password.encode("utf-8"), bcrypt.gensalt()).decode("utf-8")
|
||
|
|
|
||
|
|
|
||
|
|
def check_password(password: str, password_hash: str) -> bool:
|
||
|
|
return bcrypt.checkpw(password.encode("utf-8"), password_hash.encode("utf-8"))
|