17 lines
376 B
Python
17 lines
376 B
Python
import bcrypt
|
|
|
|
def hash_password(
|
|
password: str
|
|
) -> bytes:
|
|
salt = bcrypt.gensalt()
|
|
pwd_bytes: bytes = password.encode()
|
|
return bcrypt.hashpw(pwd_bytes, salt)
|
|
|
|
def validate_password(
|
|
password: str,
|
|
hashed_password: bytes
|
|
) -> bool:
|
|
return bcrypt.checkpw(
|
|
password=password.encode(),
|
|
hashed_password=hashed_password
|
|
) |