3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php /* * PHP mcrypt - Basic encryption and decryption of a string */ $string = "Some text to be encrypted"; $secret_key = "This is my secret key"; // Create the initialization vector for added security. $iv = 'adfa23rsdf'; // Encrypt $string $encrypted_string = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $secret_key, $string, MCRYPT_MODE_CBC, $iv); // Decrypt $string $decrypted_string = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $secret_key, $encrypted_string, MCRYPT_MODE_CBC, $iv); echo "Original string : " . $string . "<br />\n"; echo "Encrypted string : " . $encrypted_string . "<br />\n"; echo "Decrypted string : " . $decrypted_string . "<br />\n"; ?>
Output for 7.0.6 - 7.1.0
Fatal error: Uncaught Error: Call to undefined function mcrypt_encrypt() in /in/U5Ati:12 Stack trace: #0 {main} thrown in /in/U5Ati on line 12
Process exited with code 255.
Output for 5.6.8 - 5.6.20, 7.0.0 - 7.0.5
Warning: mcrypt_encrypt(): Key of size 21 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/U5Ati on line 12 Warning: mcrypt_decrypt(): Key of size 21 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported in /in/U5Ati on line 15 Original string : Some text to be encrypted<br /> Encrypted string : <br /> Decrypted string : <br />
Output for 5.4.34 - 5.5.34, hhvm-3.10.0 - 3.12.0
Warning: mcrypt_encrypt(): The IV parameter must be as long as the blocksize in /in/U5Ati on line 12 Warning: mcrypt_decrypt(): The IV parameter must be as long as the blocksize in /in/U5Ati on line 15 Original string : Some text to be encrypted<br /> Encrypted string : ��nSp�?O�Xx���wr��;�Y ��-<br /> Decrypted string : Some text to be encrypted<br />
Output for 5.0.0 - 5.4.32, 5.5.35, 5.6.21 - 5.6.28
Fatal error: Call to undefined function mcrypt_encrypt() in /in/U5Ati on line 12
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: mcrypt_encrypt() in /in/U5Ati on line 12
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: mcrypt_encrypt() in /in/U5Ati on line 12
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: mcrypt_encrypt() in /in/U5Ati on line 12