title: AES mcrypt_encrypt key size
body: <pre><code>256 bit  = 256/8 = 32
  192 bit = 192/8 = 24
  128 bit = 128/8 = 16
  
  &lt;?PHP
  include("AES.php"); // http://aesencryption.net/
      $string = "myawesometext to encrypt!";
      $key = "1234567890123456789012345";
      $block = 256;
      $aes = new AES($string, $key, $block);
      $enc = $aes-&gt;encrypt();
      $aes-&gt;setData($enc);
      $dec= $aes-&gt;decrypt();
      echo "After encryption: ".$enc."&lt;br/&gt;";
      echo "After decryption: ".$dec."&lt;br/&gt;";
  ?&gt;
  </code></pre>
  
  <p><strong><em>Error: mcrypt_decrypt(): Key of size 25 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported</em></strong></p>
  
  <p>When i use this site: <a href="http://aesencryption.net/" rel="nofollow">http://aesencryption.net/</a>
  the encryption and decryption works perfectly.
  <em>PHP: 5.6.3</em></p>
  
  <p>changing the key size is not really an option, seeing how this should be working.</p>
  
  <p>Why am i using AES?
  I am communicating between two servers (one being a third party) and the information being transferred in the communication could be a security leak if not encrypted. otherwise i would use a hashing. This data <strong>needs</strong> to be recoverable by a 3rd party with a key.</p>
  
  <p><strong>IMPORTANT:</strong></p>
  
  <ul>
  <li>Current PHP version: 5.6.3 //does not work </li>
  <li>Last PHP version: 5.5.15//works</li>
  </ul>
  
  <p><strong>----------------SOLVED</strong></p>
  
  <p>version: 5.6.0
  " <strong>Invalid key and iv sizes are no longer accepted</strong>. mcrypt_encrypt() will now throw a warning and return FALSE if the inputs are invalid. Previously keys and IVs were padded with '\0' bytes to the next valid size. " - <a href="http://php.net/manual/en/function.mcrypt-encrypt.php" rel="nofollow">http://php.net/manual/en/function.mcrypt-encrypt.php</a></p>