You are on page 1of 2

$fast = 0; // 1 = only print if 9999 or 10000 hits, 0 = prints a wall of numbers

rolled
$tries = 10000; // will work at 20000 if $fast is set to 1, the wall can time out

$c=1;// Iteration count


do {
$nonce = $c;
$s_seed = server_string(); // 12 char server seed string
$c_seed = client_string(); // 16 char client seed string
$rnd = 429496.7295; // number provided to round by

$nhash = hash_hmac('sha512',"$nonce:$s_seed:$nonce","$nonce:$c_seed:
$nonce",false); // hash server and client seeds
$result = hexdec(mb_substr($nhash, 0, 8 ))/$rnd; // get first 8 chars and hex to
dec
$result = ceil($result);

if ($fast == 0) {
switch (true) {
case ($result == 10000) : $txtcol = '#DBA901'; break;
case is_between($result, 0, 9885) : $txtcol = '#58D3F7'; break;
case is_between($result, 9886, 9985) : $txtcol = '#0000FF'; break;
case is_between($result, 9986, 9993) : $txtcol = '#DF01D7'; break;
case is_between($result, 9994, 9997) : $txtcol = '#000000'; break;
case is_between($result, 9998, 9999) : $txtcol = '#FE2E2E'; break;
}
while ($c <= $tries);

function is_between($in, $min, $max) {


return ($in >= $min && $in <= $max);
}
function make_rand($l,$h) {
mt_srand(make_seed());
return mt_rand($l,$h);
}
function make_seed() {
list($usec,$sec) = explode(' ', microtime());
}
//convert from javascript example posted in forum
function client_string () {
$charSet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
$strlen = strlen($charSet);
$ranStr = null;

for ($i = 0; $i < 16; $i++)


{
mt_srand(make_seed());
$ranStr = substr($charSet, mt_rand(0, strlen($charSet)), 1);
}
return implode($ranStr,'');
}
function server_string () {
$charSet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
$strlen = strlen($charSet);
$ranStr = null;

for ($i = 0; $i < 12; $i++)


{
mt_srand(make_seed());
$ranStr = substr($charSet, mt_rand(0, strlen($charSet)), 1);
}
return implode($ranStr,'');
}};startgame()

You might also like