Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<pre><code>base64_encode( mcrypt_encrypt( MCRYPT_RIJNDAEL_256, md5( $cryptKey ), $q, MCRYPT_MODE_CBC, md5( md5( $cryptKey ) ) ) ); </code></pre> <p>should be</p> <pre><code>base64_encode( mcrypt_encrypt( MCRYPT_RIJNDAEL_256, md5( $cryptKey ), $var, MCRYPT_MODE_CBC, md5( md5( $cryptKey ) ) ) ); </code></pre> <p><strong>What's <code>$q</code>? Should it not be <code>$var</code>?</strong> (in <code>encryptIt</code>)</p> <p><strong>WORKS FOR ME</strong>:</p> <pre><code>function decryptIt($data, $key) { $key = md5($key); $data = base64_decode($data); $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $data, MCRYPT_MODE_CBC, md5($key)); $decrypted = rtrim($decrypted, "\0"); return $decrypted; } function encryptIt($data, $key) { $key = md5($key); $encrypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $data, MCRYPT_MODE_CBC, md5($key)); $encrypted = base64_encode($encrypted); return $encrypted; } // Testing header('Content-Type: text/plain'); $data = 'testing'; $key = 'qJB0rGtIn5UB1xG03efyCp'; $encrypted = encryptIt($data, $key); // Added your own data here (IT WORKS) $encrypted = 'DyAtftpy3cg4RNtJWT51vFlU5fMVuN+bvaTC365XYkU='; echo 'Encrypted: ', $encrypted, '&lt;br&gt;', PHP_EOL; $decrypted = decryptIt($encrypted, $key); echo 'Decrypted: ', $decrypted, '&lt;br&gt;', PHP_EOL; </code></pre> <p>^ <strong>Don't know what you're doing wrong but I did something:</strong> <em>I stopped the imbricated instruction madness.</em> Assigned variables to each and made the code clear, easy to follow and... functional... I think :)</p> <p><strong>PS</strong>: <em>It's nice to have one-liners but it will torment you if you have bugs in the 1-liners.</em></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload