From 95e62c90c5c0d9ebade4d611e321864034253e06 Mon Sep 17 00:00:00 2001 From: Krzysztof Kwiatkowski Date: Fri, 27 Oct 2017 14:14:20 +0100 Subject: [PATCH] AES in python --- README.md | 1 + aes.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 aes.py diff --git a/README.md b/README.md index e69de29..d2b51d3 100644 --- a/README.md +++ b/README.md @@ -0,0 +1 @@ +``aes.py`` : AES in python3 \ No newline at end of file diff --git a/aes.py b/aes.py new file mode 100644 index 0000000..84b9c5e --- /dev/null +++ b/aes.py @@ -0,0 +1,15 @@ +from Crypto.Cipher import AES + +k=0x4645444342413938373635343332310a +m=0x97B3C8E55AEBAD9B9A802AC020272BCE + +key=(k).to_bytes(16, byteorder='big') +msg=(m).to_bytes(16, byteorder='big') + +obj = AES.new(key, AES.MODE_ECB) +enc = obj.encrypt(msg) +dec = obj.decrypt(enc) + +print("ENC=" + ''.join(['{:02x}'.format(i) for i in enc])) +print("DEC=" + ''.join(['{:02x}'.format(i) for i in dec])) +