[pycrypto] AES decrypting issues

Mike Driscoll mdriscoll at co.marshall.ia.us
Wed Oct 7 10:06:46 CST 2009


Hi,

I am working on a project where I need to decrypt some data that has
been encrypted with AES. Our webmaster gave me a PHP example that he 
uses, but I'm supposed to use Python. Here's the PHP code:

$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
return rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key,
$data,MCRYPT_MODE_ECB, $iv),"\0");

I've been told on c.l.py that the iv in this case should be 16 bytes.

I tried following the example on this blog by modifying it as needed:

http://www.codekoala.com/blog/2009/aes-encryption-python-using-pycrypto/

But no matter which base64 decode method I use, I get some kind of 
error: b32decode, b64decode and decodestring all return a padding error 
whereas b16decode claims that I don't have only 16-bit characters in my 
data string.

I've never done this before, so I'm not sure where I'm going wrong. Any 
advice would be appreciated. I'm on Windows XP with Python 2.5.

Thanks,

Mike



More information about the pycrypto mailing list