3v4l.org

run code in 300+ PHP versions simultaneously
<?php // // // EmpireDrop Provably Fair Case Battles // // // /* * Fill in all three below and click the blue 'eval();' button. ------------------ */ $server_seed = ''; $client_seed = ''; $nonce = $roundNumber = 0; /* ------------------ */ if ($server_seed == '' || $client_seed == '' || $nonce < 0) { echo "Fill in details"; return; } define('MIN_RESULT', 0.00001); define('MAX_RESULT', 100); define('CONVERT_RATE', 100000); define('HASH_TYPE', 'sha256'); function getProvablyFairResult(string $client_seed, string $server_seed, int $nounce) { $hash = hash_hmac(HASH_TYPE, "{$client_seed}-{$nounce}", $server_seed); $normalized = hexdec($hash) / (16 ** strlen($hash)); $roll = MIN_RESULT + $normalized * (MAX_RESULT - MIN_RESULT); return convertDecimalValue($roll); } function convertDecimalValue(float $value): int { return round($value * CONVERT_RATE); } $result = getProvablyFairResult($client_seed, $server_seed, $nonce); echo "Result: {$result}";
Output for git.master_jit, git.master, rfc.property-hooks
Fill in details

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
24.35 ms | 405 KiB | 5 Q