Python Encrypto Library
Fernet
对称加解密
生成密钥
kdf = PBKDF2HMAC(
algorithm=hashes.SHA256(),
length=32,
salt=salt,
iterations=390000,
)
key = base64.urlsafe_b64encode(kdf.derive(password))
print(key)
加解密
password_encrypt = Fernet(key).encrypt(password)
print(password_encrypt)
password_decrypt = Fernet(key).decrypt(password_encrypt).decode()
print(password_decrypt)