Files
SMANAGE/backup/_flask_backup/Utils/Safe.py
T

21 lines
666 B
Python

from tools import *
from AppBridge import *
from Utils.Config import *
from Utils.Models import *
class BCrypt:
def __init__(self):
pass
@staticmethod
def Gen(s: str | bytes, encoding: str = "UTF-8"):
if type(s) == str: s = s.encode(encoding)
salt = bcrypt.gensalt(rounds = 12)
HashedPassWord = bcrypt.hashpw(s, salt)
return HashedPassWord.decode(encoding)
@staticmethod
def Verify(a: str | bytes, b: str | bytes, encoding: str = "UTF-8") -> bool:
if type(a) == str: a = a.encode(encoding)
if type(b) == str: b = b.encode(encoding)
return bcrypt.checkpw(a, b)