File size: 1,227 Bytes
6ab520d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
from passlib.context import CryptContext
pwd_context = CryptContext(schemes=["argon2"], deprecated="auto")
def verify_password(plain_password, hashed_password):
"""
Verifies if the provided plain password matches the hashed password.
This function compares a plain password with a hashed password to check if they
match using the Argon2 hashing algorithm. It returns `True` if the passwords match,
otherwise returns `False`.
Args:
plain_password (str): The plain text password to be verified.
hashed_password (str): The hashed password to compare against.
Returns:
bool: `True` if the plain password matches the hashed password, otherwise `False`.
"""
return pwd_context.verify(plain_password, hashed_password)
def get_password_hash(password):
"""
Hashes the provided password using the Argon2 algorithm.
This function generates a hashed version of the given plain text password using
the Argon2 hashing algorithm. The resulting hash can be used for secure password storage.
Args:
password (str): The plain text password to be hashed.
Returns:
str: The hashed password.
"""
return pwd_context.hash(password)
|