<?php
function roll($seed, $key, $nonce) {
$key = "your client seed"; // excluding the dash and the nonce!
$seed = "your server seed";
// 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);
?>
preferences:
25.14 ms | 408 KiB | 5 Q