import base64
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.backends import default_backend
def encrypt(key, plaintext):
iv = b'1234567890abcdef'
cipher = Cipher(algorithms.AES(key), modes.CFB(iv), backend=default_backend())
encryptor = cipher.encryptor()
ciphertext = encryptor.update(plaintext) + encryptor.finalize()
return base64.b64encode(ciphertext).decode('utf-8')
key = b'your_secret_key_here' # 实际使用时需要更复杂的密钥生成方法
plaintext = "Sensitive Data"
encrypted_text = encrypt(key, plaintext.encode('utf-8'))
print(f"Encrypted Text: {encrypted_text}")