3v4l.org

run code in 300+ PHP versions simultaneously
<?php $key = hex2bin('404142434445464748494a4b4c4d4e4f'); $iv = hex2bin('10111213141516'); $aad = hex2bin('0001020304050607'); $plaintext = hex2bin('2021222'); $C = hex2bin('2021222'); $T = hex2bin('6084341b'); $tag = null; $cipher = openssl_encrypt($plaintext, 'aes-128-ccm', $key, OPENSSL_RAW_DATA, $iv, $tag, "", 4); var_dump( bin2hex($cipher), bin2hex($C), bin2hex($tag), bin2hex($T) ); /* private byte[] K1 = Hex.decode("404142434445464748494a4b4c4d4e4f"); private byte[] N1 = Hex.decode("10111213141516"); private byte[] A1 = Hex.decode("0001020304050607"); private byte[] P1 = Hex.decode("20212223"); private byte[] C1 = Hex.decode("7162015b4dac255d"); private byte[] T1 = Hex.decode("6084341b"); */ /* var_dump('411d89ff74205c106d8d85a8'); // What we want echo PHP_EOL; $key = base64_decode('Z4lAXU62WxDi46zSV67FeLj3hSK/th1Z73VD4/y6Eq4='); $iv = base64_decode('rcFcdcgZ3Q/A+uHW'); $data = 'test'; $tag = null; $encrypted = openssl_encrypt($data,'aes-128-ccm', $key, OPENSSL_RAW_DATA, $iv, $tag, "", 8); var_dump(bin2hex($encrypted . $tag)); $encrypted = openssl_encrypt($data,'aes-192-ccm', $key, OPENSSL_RAW_DATA, $iv, $tag, "", 8); var_dump(bin2hex($encrypted . $tag)); $encrypted = openssl_encrypt($data,'aes-256-ccm', $key, OPENSSL_RAW_DATA, $iv, $tag, "", 8); var_dump(bin2hex($encrypted . $tag)); $encrypted = openssl_encrypt($data,'aes-128-gcm', $key, OPENSSL_RAW_DATA, $iv, $tag, "", 8); var_dump(bin2hex($encrypted . $tag)); $encrypted = openssl_encrypt($data,'aes-192-gcm', $key, OPENSSL_RAW_DATA, $iv, $tag, "", 8); var_dump(bin2hex($encrypted . $tag)); $encrypted = openssl_encrypt($data,'aes-256-gcm', $key, OPENSSL_RAW_DATA, $iv, $tag, "", 8); var_dump(bin2hex($encrypted . $tag)); */
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0 - 8.5.1
Warning: hex2bin(): Hexadecimal input string must have an even length in /in/Vv691 on line 6 Warning: hex2bin(): Hexadecimal input string must have an even length in /in/Vv691 on line 8 Fatal error: Uncaught Error: Call to undefined function openssl_encrypt() in /in/Vv691:12 Stack trace: #0 {main} thrown in /in/Vv691 on line 12
Process exited with code 255.
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 5.6.0 - 5.6.40
Warning: hex2bin(): Hexadecimal input string must have an even length in /in/Vv691 on line 6 Warning: hex2bin(): Hexadecimal input string must have an even length in /in/Vv691 on line 8 Fatal error: Call to undefined function openssl_encrypt() in /in/Vv691 on line 12
Process exited with code 255.

preferences:
70.56 ms | 409 KiB | 5 Q