Pure Python implementation of AES for 2.7 or 3.x
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 32 commits ahead, 5 commits behind caller9:master.
Latest commit b68bfe6 Jul 27, 2017

readme.md

Build Status

This repo is the pure speed fork of caller9's original library. This version does not handle padding. It implements CBC, CFB, & OFB

# given a key, iv, & blocksize
from aespython import expandKey, AESCipher, CBCMode
expandedkey = expandKey(key) # key must be of length 16, 24, or 32
cipher = AESCipher(expandedkey)
cbc = CBCMode(cipher)
cbc.set_iv(iv) # iv must be of length 16

# user is responsible to make sure data is padded to a multiple of 16 in length
encryptedblock0 = cbc.encrypt_block(data[0:16])
encryptedblock1 = cbc.encrypt_block(data[16:32])