Overview
Encrypting sensitive data (tokens, keys, credit card numbers) at rest is crucial to prevent data breaches. Flet provides utility methods for symmetric encryption and decryption of text data.
Algorithm
cryptography package (AES 128 with hardening).Secret Key
import os
secret_key = os.getenv("MY_APP_SECRET_KEY")
export MY_APP_SECRET_KEY=""
Encryption
flet.security.encrypt() method.from flet.security import encryptsecret_key = os.getenv("MY_APP_SECRET_KEY")
plain_text = "This is a secret message!"
encrypted_data = encrypt(plain_text, secret_key)
Decryption
flet.security.decrypt() method.from flet.security import decryptsecret_key = os.getenv("MY_APP_SECRET_KEY")
encrypted_data = "..."
plain_text = decrypt(encrypted_data, secret_key)
print(plain_text)
Platform Support
cryptography package can be installed.Dependencies
cryptography package.
Previous
arrow_back
Drag and drop