3v4l.org

run code in 500+ PHP versions simultaneously
<?php $serverSeed = getenv('PF_SERVER_SEED') ?: '...'; // 32 hex $serverSalt = getenv('PF_SERVER_SALT') ?: '...'; // 16 hex $publicHash = getenv('PF_PUBLIC_HASH') ?: '...'; // 64 hex $clientSeed = getenv('PF_CLIENT_SEED') ?: '...'; $nonce = (int) (getenv('PF_NONCE') ?: 0); $maxRoll = (int) (getenv('PF_MAX_ROLL') ?: 100000); $expectedRoll = getenv('PF_EXPECTED_ROLL') !== false ? (int) getenv('PF_EXPECTED_ROLL') : null; // ─────────────────────────────────────────────────────────────────────────── $roll = (hexdec(substr(hash_hmac('sha512', $serverSeed, "$clientSeed-$nonce"), 0, 15)) % $maxRoll) + 1; $hashOk = hash_equals($publicHash, hash_hmac('sha256', $serverSeed, $serverSalt)); printf("public hash matches: %s\n", $hashOk ? 'YES' : 'NO'); printf("roll: %d (full 1..%d)\n", $roll, $maxRoll); if ($expectedRoll !== null) { printf("matches API roll (%d): %s\n", $expectedRoll, $roll === $expectedRoll ? 'YES' : 'NO'); }
Output for git.master_jit, git.master
public hash matches: NO roll: 64331 (full 1..100000)

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:
46.58 ms | 767 KiB | 4 Q