Files
ygg-service/backend/security.py
2025-11-11 20:14:58 +01:00

19 lines
550 B
Python

from passlib.context import CryptContext
# Configuration sensible : tu peux ajuster time_cost, memory_cost, parallelism
pwd_context = CryptContext(
schemes=["argon2"],
deprecated="auto",
argon2__time_cost=3,
argon2__memory_cost=64 * 1024, # 64 MB
argon2__parallelism=2
)
def hash_password(plain: str) -> str:
return pwd_context.hash(plain)
def verify_password(plain: str, hashed: str) -> bool:
return pwd_context.verify(plain, hashed)
def needs_rehash(hashed: str) -> bool:
return pwd_context.needs_update(hashed)