AES decrypting in Python

Heikki Toivonen hjtoi-better-remove-before-reply at comcast.net
Wed Oct 7 14:12:06 EDT 2009


Mike Driscoll wrote:
> EVP.Cipher(alg="aes_256_ecb", key=SomeKey, iv=SomeIV, op=dec,
> padding=False)
> 
> I don't really see where I pass the data that needs the decrypting
> though. Can someone shed some light on this?

Look at test_AES method in
http://svn.osafoundation.org/m2crypto/trunk/tests/test_evp.py

Basically EVP.Cipher returns the cipher object. You call the update
update(data) method on it (you can call this many times if you have lots
of data), which returns (possibly partial) result and finally call the
final() method to finish, which will return the last piece of the
decrypted data.

You might also want to take a look at m2secret[1] which is a small
library/utility built on top of M2Crypto to encrypt/decrypt stuff. By
default it uses AES.

[1] http://www.heikkitoivonen.net/m2secret/

-- 
  Heikki Toivonen - http://heikkitoivonen.net



More information about the Python-list mailing list