[PYTHON-CRYPTO] Question using an AES decryption

Alex alex.wied at GMAIL.COM
Thu Feb 15 20:39:25 CET 2007


first off this is library is awesome stuff! 

I would like to encrypt some text with AES. Following the DES example in 
the Crypto manual I have the following piece of code:

# Encrypt some text with 256bit AES
from Crypto.Cipher import *
plain="this is some textXXXXXXXXXXXXXXX"  # make text len multiple of 16
obj = AES.new('1234567812345678', AES.MODE_CBC, 'bbbbbbbbaaaaaaaa')
print "Before encryption: ", plain
ciph = obj.encrypt(plain)
print "After decryption: ", ciph
print "After decryption: ", obj.decrypt(ciph)

Here's the result I'm getting:

Before encryption:  this is some textXXXXXXXXXXXXXXX
After encryption:  ¸9Œ†¾{.'PÃWÄ	t”æeäVñ¤Bx•¹QÚ–
After decryption:  ‚ìnõúµYPžt‘øDޏtXXXXXXXXXXXXXXX

The decryption doesn't work as expected, I'm not receiving my original 
text. I guess I'm passing the wrong parameters to instantiate my AES 

Any ideas?

Thanks in advance for your help.


More information about the python-crypto mailing list