3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $algo = 'aes-256-gcm'; $iv = random_bytes(openssl_cipher_iv_length($algo)); $key = random_bytes(32); // 256 bit //$data = random_bytes(1024); // 1 Kb of random data $data = "well hello there"; $ciphertext = openssl_encrypt( $data, $algo, $key, OPENSSL_RAW_DATA, $iv, $tag ); // Change 1 bit in ciphertext // $i = rand(0, mb_strlen($ciphertext, '8bit') - 1); // $ciphertext[$i] = $ciphertext[$i] ^ chr(1); echo(base64_encode($ciphertext)); echo("\n"); echo(base64_encode($tag)); $i = rand(0, mb_strlen($tag, '8bit') - 1); $tag[$i] = $tag[$i] ^ chr(1); echo("\n"); echo(base64_encode($tag)); $decrypt = openssl_decrypt( $ciphertext, $algo, $key, OPENSSL_RAW_DATA, $iv, $tag ); if (false === $decrypt) { throw new Exception(sprintf( "OpenSSL error: %s", openssl_error_string() )); } printf ("Decryption %s\n", $data === $decrypt ? 'Ok' : 'Failed');
Output for 7.0.0 - 7.3.0beta2
Fatal error: Uncaught Error: Call to undefined function openssl_cipher_iv_length() in /in/Z6jTA:3 Stack trace: #0 {main} thrown in /in/Z6jTA on line 3
Process exited with code 255.
Output for hhvm-3.22.0
cvdiK1rBB1c/dwLsf1EX8A== euwSNBlZP/3iyeD3GQRbbw== euwSNBlYP/3iyeD3GQRbbw== Fatal error: Uncaught exception 'Exception' with message 'OpenSSL error: ' in /in/Z6jTA:-1 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.21.3
eKayOGNargHNTl+7K92/Qg== S8bySQNhxTSCLKEXKQQDxQ== S8bySQNhxTSCLKEXKQUDxQ== Fatal error: Uncaught exception 'Exception' with message 'OpenSSL error: ' in /in/Z6jTA:36 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.21.0
aGycYUXrYLlblS5t08d8dQ== ncH24pimlu7PyduWELXDig== ncH24pimlu7PyduWEbXDig== Fatal error: Uncaught exception 'Exception' with message 'OpenSSL error: ' in /in/Z6jTA:36 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.20.2
EFzIE5apkO7ULBVyRkQK/w== imGjrk7I9GYZsCMyrrY3kg== imGjrk7I9GYZsCMyr7Y3kg== Fatal error: Uncaught exception 'Exception' with message 'OpenSSL error: ' in /in/Z6jTA:36 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.19.2
VVViTfCZC4m5KuXpFrcNkA== jCe4f65mVTf+2qIPS2/9PQ== jCe4f65mVTf+2qIOS2/9PQ== Fatal error: Uncaught exception 'Exception' with message 'OpenSSL error: ' in /in/Z6jTA:36 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.18.5
Wfvj1F1nf1goedVGGm+ryA== mv00vJQdwSJ23MbVRY+VGQ== mvw0vJQdwSJ23MbVRY+VGQ== Fatal error: Uncaught exception 'Exception' with message 'OpenSSL error: ' in /in/Z6jTA:36 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.18.4
5DqFa3Grqfz08V9GOVBH+g== tmbqLC/4ZN4WWrukvzA6oQ== tmbqLC/4ZN4WW7ukvzA6oQ== Fatal error: Uncaught exception 'Exception' with message 'OpenSSL error: ' in /in/Z6jTA:36 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.15.4
4gs2pDpqSADRx48rQet7GQ== bqJmJEa5Mk/YFYQ+mbeQ4g== bqJmJEa5Mk7YFYQ+mbeQ4g== Fatal error: Uncaught exception 'Exception' with message 'OpenSSL error: ' in /in/Z6jTA:36 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.30
Fatal error: Call to undefined function random_bytes() in /in/Z6jTA on line 3
Process exited with code 255.