Skip to content

Instantly share code, notes, and snippets.

@lopes
lopes / aes-ecb.py
Created July 4, 2016 12:28
Simple Python example of AES in ECB mode.
from hashlib import md5
from base64 import b64decode
from base64 import b64encode
from Crypto.Cipher import AES
# Padding for the input string --not
# related to encryption itself.
BLOCK_SIZE = 16 # Bytes
pad = lambda s: s + (BLOCK_SIZE - len(s) % BLOCK_SIZE) * \