3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function roll($seed, $key, $nonce) { $key = "c52e2851529697f47fa4"; // excluding the dash and the nonce! $seed = "aa8efabd3f69a26e3f52dd9b28ecb7df68fbc5948d80b92725f23b1e4c6b3c23"; // bet made with seed pair (excluding current bet) $nonce = 0; $hash = hash_hmac('sha512', $key . '-' . $nonce, $seed); $index = 0; $lucky = hexdec(substr($hash, $index * 5, 5)); while ($lucky >= pow(10, 6)) { $index++; $lucky = hexdec(substr($hash, $index * 5, 5)); if ($index * 5 + 5 > 128) { return '99.99'; break; } } $lucky %= pow(10, 4); $lucky = sprintf('%.2f', bcdiv($lucky, '100', 2)); return $lucky; } echo roll('bla','blah',2); ?> <?php function roll($seed, $key, $nonce) { $key = "c52e2851529697f47fa4"; // excluding the dash and the nonce! $seed = "aa8efabd3f69a26e3f52dd9b28ecb7df68fbc5948d80b92725f23b1e4c6b3c23"; // bet made with seed pair (excluding current bet) $nonce = 0; $hash = hash_hmac('sha512', $key . '-' . $nonce, $seed); $index = 0; $lucky = hexdec(substr($hash, $index * 5, 5)); while ($lucky >= pow(10, 6)) { $index++; $lucky = hexdec(substr($hash, $index * 5, 5)); if ($index * 5 + 5 > 128) { return '99.99'; break; } } $lucky %= pow(10, 4); $lucky = sprintf('%.2f', bcdiv($lucky, '100', 2)); return $lucky; } echo roll('bla','blah',2); echo $hash; ?> <?php echo hash('sha512', '3d7ff67a23443ccfc42c065ab588700d886b310c805fc850b97c39d112ec9a6e'); ?>
based on qUumO
Output for 5.5.0 - 5.6.30, 7.0.0 - 7.1.4
Fatal error: Cannot redeclare roll() (previously declared in /in/q4fbd:2) in /in/q4fbd on line 62
Process exited with code 255.
Output for hhvm-3.12.14 - 3.17.3
Fatal error: Uncaught Error: Cannot redeclare roll() (previously declared in /in/q4fbd:29) in /in/q4fbd:62 Stack trace: #0 {main}
Process exited with code 255.