Last active
June 8, 2023 06:12
-
-
Save TheAlchemistKE/093af92e8c1e679e9abfc997fcfa7084 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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