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(32); $iv = openssl_random_pseudo_bytes(16); $cipher = mcrypt_encrypt( MCRYPT_RIJNDAEL_128, $key, $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 );
based on oBPR0
Output for 7.2.6
Fatal error: Uncaught Error: Call to undefined function openssl_random_pseudo_bytes() in /in/gI9hT:11 Stack trace: #0 {main} thrown in /in/gI9hT 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/gI9hT:14 Stack trace: #0 {main} thrown in /in/gI9hT on line 14
Process exited with code 255.
Output for hhvm-3.15.4
string(4) "test" string(8) "918c1623" string(4) "�\�" int(4) int(4) bool(false)
Output for 5.6.0 - 5.6.30
Fatal error: Call to undefined function mcrypt_encrypt() in /in/gI9hT on line 14
Process exited with code 255.