Question about crypto

Anthony Papillion papillion at gmail.com
Sun Aug 18 17:56:57 EDT 2013


I've just started working with the Crypto library and I've already run
into a wall even though I'm following a tutorial. Basically, I'm trying
to encrypt a string using AES in CBC mode. Here is the code:

from Crypto import AES
import hashlib

text_to_encrypt = 'This is a super secret encrypted message, yo!'
key = '0123456789abcdef'
mode = AES.MODE_CBC
encryptor = AES.new(key, mode)

ciphertext = encryptor.encrypt(text)

When I run the code above, I am told that the IV must be 16 bytes long.
I'm assuming that the IV (I know that means "Initialization Vector") is
either the key OR something else I can set. But I don't know how or what
to do.

Does anyone see what is wrong with the code above and could suggest ways
to make it work? I've spent the last 45 minutes googling around and
nothing comes up specific to my problem.

Thanks,
Anthony



More information about the Python-list mailing list