title: AES decryption using pycrypto
body: <p>As a self study exercise, I'm trying to learn how to use some of the pycrypto library. I need to decrypt a ciphertext string in CBC_MODE using AES. I the ciphertext, key, and IV are all given. Here is the code that I have written:</p>
  
  <pre><code>from Crypto.Cipher import AES
  
  mode = AES.MODE_CBC
  key = "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1"
  ciphertext = "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1";
  
  iv = ciphertext[:32] 
  ciphertext = ciphertext[32:] 
  decryptor = AES.new(key, mode, iv)
  plaintext = decryptor.decrypt(ciphertext)
  print plaintext
  </code></pre>
  
  <p>When I run this, I get the following error:</p>
  
  <blockquote>
    <p>ValueError: IV must be 16 bytes long</p>
  </blockquote>
  
  <p>I know that the IV string is 32 hex characters, and therefore 16 bytes. I think that this might be a typing problem, but I don't know how to correct it. Can anyone help?</p>
  
  <p>Thank you!</p>