def decrypt(cipher_txt, key, salt):
salt = bytes(salt.encode('latin1'))
cipher_txt = bytes(str(cipher_txt).encode('latin1'))
kdf = PBKDF2HMAC(algorithm=hashes.SHA256(), length=32, salt=salt, iterations=100000, backend=default_backend())
encrypted_key = base64.urlsafe_b64encode(kdf.derive(bytes(key.encode('utf-8'))))
f = Fernet(encrypted_key)
return f.decrypt(cipher_txt).decode('utf-8')
评论列表
文章目录