/ encryption.py
encryption.py
1 Here is an example of how to perform AES-256 encryption and decryption in Python using the `cryptography` library: 2 3 ```python 4 from cryptography.fernet import Fernet 5 from base64 import b64encode, b64decode 6 import os 7 8 class AesCipher: 9 def __init__(self): 10 self.key = Fernet.generate_key() 11 self.cipher_suite = Fernet(self.key) 12 13 def encrypt(self, data: bytes) -> str: 14 """Encrypts the given data using AES-256.""" 15 encrypted = self.cipher_suite.encrypt(data) 16 return b64encode(encrypted).decode() 17