3v4l.org

run code in 300+ PHP versions simultaneously
<?php $game_id = 2820; $client_seed = "gJyxdPdhqv"; $server_seed = "5a5e6a3494cf9572b6dc5dd6aee4263b6eec8b8f331e29c426d03f9ab6ade17f"; $idClientSeed = $client_seed . "-" . $game_id; $hex = hash_hmac("sha512", $idClientSeed, $server_seed); $index = 0; $lucky = hexdec(substr($hex, $index * 5, (($index * 5) - $index * 5 + 5))); while ($lucky >= 1e6) { $index += 1; $lucky = hexdec(substr($hex, $index * 5, (($index * 5) - $index * 5 + 5))); if ($index * 5 + 5 > 129) { $lucky = 9999; break; } } $number = ($lucky % 1e4) * 1e-2; echo "Roll: " . $number;

preferences:
81.55 ms | 406 KiB | 5 Q