PyCrypto AES MODE_CBC - How to?

Helmut Jarausch jarausch at igpm.rwth-aachen.de
Wed Feb 25 07:21:03 EST 2009


Hi,

I've just tried to write a simple example using PyCrypto's
AES (CBC mode)

#!/usr/bin/python
from Crypto.Cipher import AES

PWD='abcdefghijklmnop'
Initial16bytes='0123456789ABCDEF'

crypt = AES.new(PWD, AES.MODE_CBC,Initial16bytes)
# crypt = AES.new(PWD, AES.MODE_ECB)

txt = 'ea523a664dabaa4476d31226a1e3bab0'

c = crypt.encrypt(txt)

txt_plain=crypt.decrypt(c)

print txt_plain

Unfortunately, txt_plain differs from txt - why?
(Using MODE_ECB does work however)

What am I missing?

Many thanks for a hint,

Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany



More information about the Python-list mailing list