24 lines
665 B
Python
24 lines
665 B
Python
from cryptography.fernet import Fernet
|
|
from passlib.context import CryptContext
|
|
from const import SERCET_KEY
|
|
|
|
root_path = '/api'
|
|
pwd_context = CryptContext(schemes=["sha256_crypt"], deprecated="auto")
|
|
|
|
def root_api_path_build(path):
|
|
return root_path + path
|
|
|
|
def encryptString(strEncode: str):
|
|
fernet = Fernet(SERCET_KEY)
|
|
return fernet.encrypt(strEncode.encode())
|
|
|
|
def decryptString(strDecode: str):
|
|
fernet = Fernet(SERCET_KEY)
|
|
return fernet.decrypt(strDecode).decode()
|
|
|
|
def verify_password(plain_password, hashed_password):
|
|
return pwd_context.verify(plain_password, hashed_password)
|
|
|
|
def get_password_hash(password):
|
|
return pwd_context.hash(password)
|