3v4l.org

run code in 300+ PHP versions simultaneously
<?php $val = /*16777215 - */302; $a = myencrypt($val); echo 'a: '. $a . '<br/>'; echo mydecrypt($a) . ' should equal ' . $val; $b = myencrypt($val+1); echo 'b: '. $b . '<br/>'; echo mydecrypt($b) . ' should equal ' . $val+1; function myencrypt($data){ $data = base_convert($data, 10, 36); //$data = str_pad($data, 8, '0', STR_PAD_LEFT); $data = openssl_encrypt( $data, 'aes-128-ctr', 'key', 0, openssl_random_pseudo_bytes(openssl_cipher_iv_length('aes-128-ctr')) ); $data = str_replace('=', '', base64_encode($data)); return $data; } function mydecrypt($data) { if ($base64_safe) $data = base64_decode($data.'=='); $data = openssl_decrypt( $data, 'aes-128-ctr', 'key', 0, $iv); $data = base_convert($data, 36, 10); return $data; }
Output for 8.0.1 - 8.0.20, 8.1.0 - 8.1.7
Fatal error: Uncaught Error: Call to undefined function openssl_encrypt() in /in/0YPJm:17 Stack trace: #0 /in/0YPJm(4): myencrypt('8e') #1 {main} thrown in /in/0YPJm on line 17
Process exited with code 255.
Output for 7.4.0 - 7.4.30
Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /in/0YPJm on line 10 Fatal error: Uncaught Error: Call to undefined function openssl_encrypt() in /in/0YPJm:17 Stack trace: #0 /in/0YPJm(4): myencrypt('8e') #1 {main} thrown in /in/0YPJm on line 17
Process exited with code 255.

preferences:
21.87 ms | 410 KiB | 5 Q