editzz / backend /app /core /security.py
andevs's picture
Upload 18 files
e362ecf verified
Raw
History Blame Contribute Delete
399 Bytes
from passlib.context import CryptContext
from jose import jwt
from datetime import datetime, timedelta
from app.core.config import JWT_SECRET
pwd = CryptContext(schemes=["bcrypt"])
def hash_password(p): return pwd.hash(p)
def verify(p, h): return pwd.verify(p, h)
def create_token(data):
return jwt.encode({**data, "exp": datetime.utcnow()+timedelta(days=7)}, JWT_SECRET, algorithm="HS256")