extract password hashing into separate module

This commit is contained in:
2025-11-16 16:42:20 +01:00
parent 16bf9b54f2
commit a120512baf
2 changed files with 51 additions and 28 deletions

13
security.py Normal file
View 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)