fooder-api/fooder/utils/password_helper.py

16 lines
499 B
Python

from passlib.context import CryptContext
from ..settings import settings
class PasswordHelper:
def __init__(self, pwd_context: CryptContext):
self.pwd_context = pwd_context
def verify(self, plain_password: str, hashed_password: str) -> bool:
return self.pwd_context.verify(plain_password, hashed_password)
def hash(self, password: str) -> str:
return self.pwd_context.hash(password)
password_helper = PasswordHelper(CryptContext(settings.PASSWORD_SCHEMES))