from cryptography.fernet import Fernet # Generate key key = Fernet.generate_key() # Create Fernet object fernet = Fernet(key) # Encrypt data data = b"Hello world" encrypted_data = fernet.encrypt(data) # Decrypt data decrypted_data = fernet.decrypt(encrypted_data) print(decrypted_data)In the above code, we first generate a key using Fernet.generate_key(). We then create a Fernet object using this key and use it to encrypt the data "Hello world". We print the encrypted data and then decrypt it using the same Fernet object. Finally, we print the decrypted data. The package library used in this example is "cryptography".