3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function aesCtr(string $m, string $n, string $k): string { return \openssl_encrypt($m, 'aes-256-ctr', $k, OPENSSL_RAW_DATA, $n); } $messages = [ 'wGVEtlgIETc4E4SNly0b7viJAv3bpO/85lC5/XCssVnMlrPc+TxeI+Jrsl+wVwQVOKbCEw8=', '2GxE9VRBC3giH5XMiSQXvfnGAeGHBqlXABl1mHrcabUCi8PLNlZCe+K1+3M9Vvb9nJo0AjHjuYkARV9h8WRywgFg+VSWKLb0K0lg+ZBVN70sJ+GRLrB6mCUK/ZeYucA=', '1mgX9w0TFzd2Ty69vfYaKmioBx7KaZoHHuCYCOEG519T2EQs6HJMIIle' ]; $key = hash('sha256', 'spottycat', true); $nonce = str_repeat("\0", 16); // First, remove the base64 decoding: $base64decoded = [ base64_decode($messages[0]), base64_decode($messages[1]), base64_decode($messages[2]) ]; // The last 32 bytes are a HMAC. We can strip that. $stripLast32 = [ mb_substr($base64decoded[0], 0, -32, '8bit'), mb_substr($base64decoded[1], 0, -32, '8bit'), mb_substr($base64decoded[2], 0, -32, '8bit') ]; var_dump( bin2hex($stripLast32[0]), bin2hex($stripLast32[1]), bin2hex($stripLast32[2]), bin2hex( aesCtr($messages[0], $nonce, $key) ), bin2hex( aesCtr($messages[1], $nonce, $key) ), bin2hex( aesCtr($messages[2], $nonce, $key) ), aesCtr($messages[0], $nonce, $key), aesCtr($messages[1], $nonce, $key), aesCtr($messages[2], $nonce, $key) );
based on YVnVc
Output for 7.1.20 - 7.3.0beta1
Fatal error: Uncaught Error: Call to undefined function openssl_encrypt() in /in/97LZL:4 Stack trace: #0 /in/97LZL(35): aesCtr('wGVEtlgIETc4E4S...', '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00...', 'Q\x10\xAC\xC9\x92\xCD\xE6S\x82\xAB\x9A\x0E<EX...') #1 {main} thrown in /in/97LZL on line 4
Process exited with code 255.
Output for hhvm-3.18.5 - 3.22.0, 7.0.0 - 7.1.11
string(42) "c06544b6580811373813848d972d1beef88902fddb" string(126) "d86c44f554410b78221f95cc892417bdf9c601e18706a957001975987adc69b5028bc3cb3656427be2b5fb733d56f6fd9c9a340231e3b98900455f61f16472" string(20) "d66817f70d131737764f" string(144) "937281d0ea3d1f488b5e21e974f0c642ed7e23a791c1f96f8e2ef7f61b820668e9bf4850de79fbefcee94d55de5ae1ec929302f75a9860e9ba65fddf162fec7e7628e9632e66a456" string(256) "d672afd0a7072a438d3925b479f1cd41e854429dd0d1fe628e3d83dc29bc45089d9167549c69caffdcdd765bdb10e1c3f7ab20d1769861aae23a9b91162edf115729e4102a7bd401d351efefff703f81168bb19ca31240bf0e52b81d9a233b881e34a7193ee1c1986cf0af6ffb53539d9579a96737aeda4d68c7b3a8111c1966" string(112) "d558b0cda7264855887026ef65bda335f7614aa4eddaf94a8d20f3df0a97461894a6483cb26efddb888e1a4c806de0fc8f8f30df5afa46fe" string(72) "�r���=H�^!�t��B�~#����o�.���h�HP�y����MU�Z�쒓�Z�`�e��/�~v(�c.f�V" string(128) "�r�Ч*C�9%�y��A�TB���b�=��)�E��gT�i���v[���� �v�a��:��.�W)�*{��Q��p?�����@�R��#;�4�>�l�o�SS��y�g7��Mhdz�f" string(56) "�X�ͧ&HU�p&�e��5�aJ���J� �� �F��H<�n�ۈ�L�m��0�Z�F�"
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected ':', expecting '{' in /in/97LZL on line 3
Process exited with code 255.