title: How to decrypt by Python for AES encrypt by PHP
body: <p>I got AES encrypted hex text by PHP. This is below:</p>
  
  <p>The Code is below:</p>
  
  <pre><code>&lt;?php
  $str = "abcdefghijklmnopqrstuvwxyz";
  $method = "aes-256-cbc";
  $key = 'pqrstuvwxyz$abcdefghijAB';
  $iv = 'DEFGHTABCIESPQXO';
  echo bin2hex(openssl_encrypt($str, $method, $key, OPENSSL_RAW_DATA, $iv));
  echo "\n";
  ?&gt;
  </code></pre>
  
  <p><code>2324ab5ec7a901247bf01b08bd1956688843dad5a8e15106ca3a5b9258918527
  </code></p>
  
  <p>I made Python script:</p>
  
  <pre><code>import binascii
  from Crypto.Cipher import AES
  
  data = "abcdefghijklmnopqrstuvwxyz"
  key = "pqrstuvwxyz$abcdefghijAB"
  iv = "DEFGHTABCIESPQXO"
  
  encrypted = "2324ab5ec7a901247bf01b08bd1956688843dad5a8e15106ca3a5b9258918527"
  
  cipher = AES.new(key, AES.MODE_CBC, iv)
  decrypted = cipher.decrypt(binascii.unhexlify(encrypted))
  print(decrypted)
  </code></pre>
  
  <p>I got this, It's not same string with "abcdefghijklmnopqrstuvwxyz",:</p>
  
  <p><code>b' \xea\xbc\x13\x98!xw\x0c,\xac6\xeb\x1c\x14\\Z\x0b\x0fTY\xbe\x0b^W\xcem\xa4\x9ea\xde\x1b'
  </code></p>
  
  <p>I got an error</p>
  
  <pre><code>decrypted.decode('utf-8')
  
  UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 1-2: invalid continuation byte
  </code></pre>
  
  <p>I want to resolve for this Python Script.</p>