diff --git a/utils/helpers.py b/utils/helpers.py new file mode 100644 index 0000000..06d7405 Binary files /dev/null and b/utils/helpers.py differ diff --git a/utils/logging.py b/utils/logging.py new file mode 100644 index 0000000..06d7405 Binary files /dev/null and b/utils/logging.py differ diff --git a/utils/security.cpython-311.pyc b/utils/security.cpython-311.pyc new file mode 100644 index 0000000..35ca365 Binary files /dev/null and b/utils/security.cpython-311.pyc differ diff --git a/utils/security.py b/utils/security.py new file mode 100644 index 0000000..4a6947e --- /dev/null +++ b/utils/security.py @@ -0,0 +1,18 @@ +from passlib.context import CryptContext +from jose import jwt +from datetime import datetime, timedelta +from config.settings import settings + +pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto") + +def get_password_hash(password: str) -> str: + return pwd_context.hash(password) + +def verify_password(plain_password: str, hashed_password: str) -> bool: + return pwd_context.verify(plain_password, hashed_password) + +def create_access_token(data: dict) -> str: + to_encode = data.copy() + expire = datetime.utcnow() + timedelta(minutes=settings.access_token_expire_minutes) + to_encode.update({"exp": expire}) + return jwt.encode(to_encode, settings.secret_key, algorithm=settings.algorithm) \ No newline at end of file