title: PHP AES Decryption working Encryption NOT
body: <p>So, I have 3 Pieces out of 4 working, iOS Encrypt-Decrypt from this <a href="http://iphonedevelopment.blogspot.com/2009/02/strong-encryption-for-cocoa-cocoa-touch.html" rel="nofollow">Link</a>
  And I am able to Decrypt the data Encrypted from iOS I am having trouble Encrypting on PHP side.
  When I do echo Encryption code. PHP prints something like F>HFl8aR what does it mean ?</p>
  
  <p>SALTKEY = 'a16byteslongkey!';</p>
  
  <p>Decryption Code: <strong>Working</strong></p>
  
  <pre><code>     $result =  mcrypt_decrypt(MCRYPT_RIJNDAEL_128, (SALTKEY . str_repeat(chr(0x00), 16)), 
                                 base64_decode($text), 'ecb');
       $pad_char = ord(substr($result, -1));
       return substr($result, 0, strlen($result) - $pad_char);
  </code></pre>
  
  <p>Encryption Code : <strong>Not Working</strong></p>
  
  <pre><code>     $result =  mcrypt_encrypt(MCRYPT_RIJNDAEL_128, (SALTKEY . str_repeat(chr(0x00), 16)), 
                                 base64_encode($text), 'ecb');
       $pad_char = ord(substr($result, -1));
       return substr($result, 0, strlen($result) - $pad_char);
  </code></pre>
  
  <ul>
  <li><p><strong>Results on iOS</strong> : Text = "Hello"<br>
        Encryption = "7opqbb7sEVNoXplyQv/X8g=="<br>
        Decryption of (7opqbb7sEVNoXplyQv/X8g==) = "Hello"  </p></li>
  <li><p><strong>Results on PHP</strong> : Text = "7opqbb7sEVNoXplyQv/X8g=="<br>
        Decryption = "Hello"<br>
        Encryption of (Hello) = "_~TPn~p3MF?"   </p></li>
  </ul>