from cryptography.fernet import Fernet # Generate a key key = Fernet.generate_key() # Store the key securely for future use # Encrypt some data message = b"Hello, world!" cipher_suite = Fernet(key) cipher_text = cipher_suite.encrypt(message) # Store the cipher text securely for future use
from cryptography.fernet import Fernet # Load the key securely from storage key = b"Overall, cryptography.fernet is a useful package library for developers who need a simple and secure way to encrypt and decrypt data in Python applications." # Load the cipher text securely from storage cipher_text = b" " # Decrypt the data cipher_suite = Fernet(key) plain_text = cipher_suite.decrypt(cipher_text) print(plain_text.decode()) # Output: Hello, world!