3v4l.org

run code in 300+ PHP versions simultaneously
<?php define('SECRET', 'private-key'); $payload = [ "id" => 1, "username" => "test@example.com", "created_at" => "2018-10-11 13:30:29", "updated_at" => "2018-10-17 11:17:14" ]; echo verifySignature(SECRET, 'https://example.com/webhook', $payload, 1517949000); function verifySignature(string $secret, string $webhookUrl, array $payload, int $timestamp): string { $jsonPayload = json_encode($payload); $stringToSign = "NORDWL-HMAC-SHA256\n"; $stringToSign .= sprintf("Timestamp %d\n", $timestamp); $stringToSign .= hash('sha256', $jsonPayload); $timestampKey = hash_hmac('sha256', $timestamp, 'NORDWL' . $secret, true); $signingKey = hash_hmac('sha256', $webhookUrl, $timestampKey, true); return hash_hmac('sha256', $stringToSign, $signingKey); }
Output for 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.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
61994df60c552042e781c3c1acf5100d553647c668c1ef230bf8be585b8cff0c
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 61994df60c552042e781c3c1acf5100d553647c668c1ef230bf8be585b8cff0c
Output for 5.6.38
Parse error: syntax error, unexpected ':', expecting '{' in /in/1rvX5 on line 14
Process exited with code 255.

preferences:
178.87 ms | 401 KiB | 209 Q