3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function pkcs7_pad($str) { $len = mb_strlen($str, '8bit'); $c = 16 - ($len % 16); $str .= str_repeat(chr($c), $c); return $str; } $message = 'test'; $key = openssl_random_pseudo_bytes(16); $iv = openssl_random_pseudo_bytes(16); $cipher = mcrypt_encrypt( MCRYPT_RIJNDAEL_128, $key, pkcs7_pad($message), 'ctr', $iv ); $plain = openssl_decrypt( $cipher, 'aes-128-ctr', $key, OPENSSL_RAW_DATA, $iv ); var_dump( $message, bin2hex($cipher), $plain, mb_strlen($message, '8bit'), mb_strlen($plain, '8bit'), $message === $plain );
Output for 7.2.6
Fatal error: Uncaught Error: Call to undefined function openssl_random_pseudo_bytes() in /in/DEn2R:11 Stack trace: #0 {main} thrown in /in/DEn2R on line 11
Process exited with code 255.
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Call to undefined function mcrypt_encrypt() in /in/DEn2R:14 Stack trace: #0 {main} thrown in /in/DEn2R on line 14
Process exited with code 255.
Output for hhvm-3.15.4
string(4) "test" string(32) "005234727879291010a84d46b2ab5ece" string(16) "test " int(4) int(16) bool(false)
Output for 5.6.0 - 5.6.30
Fatal error: Call to undefined function mcrypt_encrypt() in /in/DEn2R on line 14
Process exited with code 255.