<?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');
?>
- Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.30, 7.0.0 - 7.0.18, 7.1.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.
preferences:
202.89 ms | 1400 KiB | 100 Q