gandalf at designaproduct.biz
Fri Jun 16 14:14:43 CEST 2006
> You can do this as follows:
> py> from Crypto.Cipher import AES
> py> # key has to be 16, 24 or 32 bytes for AES
> py> crypt = AES.new('abcdefghijklmnop', AES.MODE_ECB)
> # we're lucky, the string to encrypt is a multiple of 16 in length
> py> txt = 'ea523a664dabaa4476d31226a1e3bab0'
> py> c = crypt.encrypt(txt)
> py> c
> py> crypt.decrypt(c)
> see http://www.amk.ca/python/writing/pycrypt for the docs. if you have
> to encrypt data which has not a multiple of length 16 you have to pad
> it e.g. with spaces, and then strip the decrypt() result.
Or use CBC mode? I'm not familiar with pycrypto but I know that CBC mode
can crypt/decrypt text with any size.
More information about the Python-list