title: AES-128 CBC decryption in Python
body: <p>I'm trying to implement this code in python (I'm new to python) and it gives me the following error:</p>
  
  <blockquote>
    <p>AttributeError: 'str' object has no attribute 'decode'</p>
  </blockquote>
  
  <p>If we remove <code>.decode ('hex')</code> only to avoid such error:</p>
  
  <pre><code>from itertools import product
  from Crypto.Cipher import AES
  import Crypto.Cipher.AES
  
  key = ('2b7e151628aed2a6abf7158809cf4f3c').decode('hex')
  IV = ('000102030405060708090a0b0c0d0e0f').decode('hex')
  plaintext1 = ('6bc1bee22e409f96e93d7e117393172a').decode('hex')
  plaintext2 = ('ae2d8a571e03ac9c9eb76fac45af8e51').decode('hex')
  plaintext3 = ('30c81c46a35ce411e5fbc1191a0a52ef').decode('hex')
  cipher = AES.new(key, AES.MODE_CBC, IV)
  ciphertext = cipher.encrypt(plaintext1 + plaintext2 + plaintext3)
  (ciphertext).encode('hex')
  decipher = AES.new(key, AES.MODE_CBC, IV)
  plaintext = decipher.decrypt(ciphertext)
  (plaintext).encode('hex')
  </code></pre>
  
  <p>but it gives me the following error:</p>
  
  <blockquote>
    <p>ValueError: IV must be 16 bytes long</p>
  </blockquote>
  
  <p>since the algorithm would need the <code>.decode ('hex')</code> that I had to remove</p>
  
  <pre><code>from itertools import product
  from Crypto.Cipher import AES
  import Crypto.Cipher.AES
  
  key = ('2b7e151628aed2a6abf7158809cf4f3c')
  IV = ('000102030405060708090a0b0c0d0e0f')
  plaintext1 = ('6bc1bee22e409f96e93d7e117393172a')
  plaintext2 = ('ae2d8a571e03ac9c9eb76fac45af8e51')
  plaintext3 = ('30c81c46a35ce411e5fbc1191a0a52ef')
  cipher = AES.new(key,AES.MODE_CBC,IV)
  ciphertext = cipher.encrypt(plaintext1 + plaintext2 + plaintext3)
  (ciphertext).encode('hex')
  decipher = AES.new(key,AES.MODE_CBC,IV)
  plaintext = decipher.decrypt(ciphertext)
  (plaintext).encode('hex')
  </code></pre>
  
  <p>Does anyone have any idea how I could do to make this code work?</p>