extract password hashing into separate module
This commit is contained in:
13
security.py
Normal file
13
security.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from passlib.context import CryptContext
|
||||
|
||||
password_context = CryptContext(schemes=["sha256_crypt"], deprecated="auto")
|
||||
|
||||
|
||||
def hash_password(password: str) -> str:
|
||||
"""Hashes a plain text password."""
|
||||
return password_context.hash(password)
|
||||
|
||||
|
||||
def verify_password(plain_password: str, hashed_password: str) -> bool:
|
||||
"""Verifies a plain text password against a hashed password."""
|
||||
return password_context.verify(plain_password, hashed_password)
|
||||
Reference in New Issue
Block a user