Skip to content

Instantly share code, notes, and snippets.

@TheAlchemistKE
Last active June 8, 2023 06:12
Show Gist options
  • Save TheAlchemistKE/093af92e8c1e679e9abfc997fcfa7084 to your computer and use it in GitHub Desktop.
Save TheAlchemistKE/093af92e8c1e679e9abfc997fcfa7084 to your computer and use it in GitHub Desktop.
from Crypto.Cipher import AES
import os
encryption_key = os.urandom(16)
def encrypt_AES(key, data):
cipher = AES.new(key, AES.MODE_ECB)
return cipher.encrypt(data)
def decrypt_AES(key, encrypted_data):
cipher = AES.new(key, AES.MODE_ECB)
return cipher.decrypt(encrypted_data)
cipher_text = encrypt_AES(encryption_key, "This is the data".encode("utf8"))
text = decrypt_AES = decrypt_AES(encryption_key, cipher_text)
print(cipher_text)
print(text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment