3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function aesCtr(string $m, string $n, string $k): string { return \openssl_decrypt($m, 'aes-128-ctr', $k, OPENSSL_RAW_DATA, $n); } $messages = [ 'wGVEtlgIETc4E4SNly0b7viJAv3bpO/85lC5/XCssVnMlrPc+TxeI+Jrsl+wVwQVOKbCEw8=', '2GxE9VRBC3giH5XMiSQXvfnGAeGHBqlXABl1mHrcabUCi8PLNlZCe+K1+3M9Vvb9nJo0AjHjuYkARV9h8WRywgFg+VSWKLb0K0lg+ZBVN70sJ+GRLrB6mCUK/ZeYucA=', '1mgX9w0TFzd2Ty69vfYaKmioBx7KaZoHHuCYCOEG519T2EQs6HJMIIle' ]; $key = hash('sha256', 'spottycats', true); var_dump(bin2hex($key)); $nonce = str_repeat("\x00", 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]), aesCtr($messages[0], $nonce, $key), aesCtr($messages[1], $nonce, $key), aesCtr($messages[2], $nonce, $key) );
based on iX61P
Output for 7.1.20 - 7.3.0beta1
string(64) "27ba61131ac180b9c03e439dd81bc536f63b30b6009000688292f17cc086da61" Fatal error: Uncaught Error: Call to undefined function openssl_decrypt() in /in/siB90:4 Stack trace: #0 /in/siB90(35): aesCtr('wGVEtlgIETc4E4S...', '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00...', ''\xBAa\x13\x1A\xC1\x80\xB9\xC0>C\x9D\xD8\e\xC5...') #1 {main} thrown in /in/siB90 on line 4
Process exited with code 255.
Output for hhvm-3.18.5 - 3.22.0, 7.0.0 - 7.1.11
string(64) "27ba61131ac180b9c03e439dd81bc536f63b30b6009000688292f17cc086da61" string(42) "c06544b6580811373813848d972d1beef88902fddb" string(126) "d86c44f554410b78221f95cc892417bdf9c601e18706a957001975987adc69b5028bc3cb3656427be2b5fb733d56f6fd9c9a340231e3b98900455f61f16472" string(20) "d66817f70d131737764f" string(72) "�Ga� ^ (�ؾu1��W��P�u$O6�x�)�R��9c`c���5A��ξ8�ӏ@� z�C��i�" string(128) "�GO�A77UO���t:���6փ@�x$\B�J�j�&�{sQs��0 �ë�(;���Yd1�~>�B�s�t�(&Œ�����?p7�@� �g�9��Ȱ���' ��8jJ��BDN\��W7��8" string(56) "�mP�AUC �ޯ8T��>�K�P'A2�i�i�/���UtfW��kv�Ӣ &��"
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected ':', expecting '{' in /in/siB90 on line 3
Process exited with code 255.