Demo
This commit is contained in:
17
app/utils/bcrypt_utils.py
Normal file
17
app/utils/bcrypt_utils.py
Normal file
@@ -0,0 +1,17 @@
|
||||
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
|
||||
)
|
||||
Reference in New Issue
Block a user