3v4l.org

run code in 500+ PHP versions simultaneously
<?php /* * Fill in all below and click the blue 'eval();' button. * ------------------ */ $server_seed = ""; $client_seed = ""; $game_id = ""; $chance = 0.50; // your chosen chance, e.g. 0.50 for 50% $direction = "under"; // "under" or "over" /* ------------------ */ if ($server_seed == '' || $client_seed === "" || $game_id == '') { echo "Fill in details"; return; } // Create HMAC-SHA256 hash $message = $client_seed . "-" . $game_id; $hmac_hash = hash_hmac('sha256', $message, $server_seed); // Convert hex to decimal using bcmath for large numbers $decimal_value = '0'; $length = strlen($hmac_hash); for ($i = 0; $i < $length; $i++) { $decimal_value = bcmul($decimal_value, '16'); $decimal_value = bcadd($decimal_value, hexdec($hmac_hash[$i])); } // Apply modulo 10^8 $roll = (int) bcmod($decimal_value, '100000000'); // Same threshold/win check as upgrade_start_game() server-side — // house edge 0.10, symmetric under/over. $house_edge = 0.10; $multiplier = (1 - $house_edge) / $chance; $threshold = (int) ($chance * 100000000); $win = $direction !== "over" ? $roll < $threshold : $roll >= (100000000 - $threshold); echo "Roll: " . $roll . "\n"; echo $win ? ("Win \xe2\x80\x94 payout " . number_format($multiplier, 4) . "x") : "Loss"; ?>
Output for 8.2.31 - 8.2.32, 8.3.0 - 8.3.32, 8.4.1 - 8.4.24, 8.5.0 - 8.5.9
Fill in details

preferences:
45.48 ms | 761 KiB | 4 Q