3v4l.org

run code in 300+ PHP versions simultaneously
<?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) );

preferences:
57.18 ms | 402 KiB | 5 Q