# Import the cryptography module from cryptography.fernet import Fernet # Generate a new encryption key key = Fernet.generate_key() # Define the original message to be encrypted message = "Hello, world!" # Encrypt the message using the Fernet algorithm and the generated key fernet = Fernet(key) encrypted_message = fernet.encrypt(message.encode('utf-8')) # Print the resulting encrypted message print(encrypted_message) # Decrypt the encrypted message using the Fernet algorithm and the same key decrypted_message = fernet.decrypt(encrypted_message) # Print the resulting decrypted message print(decrypted_message.decode('utf-8'))