Fairness
Dice

PHP Version of the resulted Dice Game


$seed = hash_hmac('sha512', 'my server seed', 'my client seed'.':'.'my nonce');
$hex_number = hexdec(substr($seed,0,10));
$roll_number = $hex_number % 10000;
		
echo $roll_number;
Limbo

PHP Version of the resulted Limbo Game


$seed = hash_hmac('sha512', 'my server seed', 'my client seed'.':'.'my nonce');
$seed = substr($seed, 0, 52 / 4);
$hex_number = hexdec($seed) / pow(2, 52);
$multiplier = floor(95 / (1 - $hex_number)) / 100;

echo max(1, min($multiplier, 1000000));
Keno

PHP Version of the resulted Keno Game


$keno_numbers = [];
$i = 0;
while(count($numbers) <= 19){
  $seed = hash_hmac('sha512', 'my server seed', 'my client seed'.':'.'my nonce'.':'.$i);
  $seed = hexdec(substr($seed,0,10));
  $number = abs(substr(strval($seed),-4))%80;
  if(!in_array($number, $keno_numbers)){
    $keno_numbers[] = $number;
  }
  $i++;
}

print_r($keno_numbers);
Mines

PHP Version of the resulted Mines Game


$mines = [];
$i = 0;
while(count($mines) < $mines_no){
  $seed = hash_hmac('sha512', 'my server seed', 'my client seed'.':'.'my nonce'.':'.$i);
  $seed = strval(hexdec(substr($seed,0,10)));
  $mine_pos = abs(substr($seed,-4))%25;
  if($mine_pos != 0 && !in_array($mine_pos, $mines)){
    $mines[] = $mine_pos;
  }
  $i++;
}

echo $mines;
Towers

PHP Version of the resulted Towers Game


$bloks_data    = [];

$elements   = 8 * $col_tnt;

$n 			= 0;
$row 		= 1;
$i 	        = 0;

while($i < $elements){
    $seed = hash_hmac('sha512', 'my server seed', 'my client seed'.':'.'my nonce'.':'.$i);

    $seed 	= strval(hexdec(substr($seed,0,10)));
    $number 	= abs(substr($seed,-4))%$columns;

    if(!isset($bloks_data[$row])){
        $bloks_data[$row] = [];
    }

    if(!in_array($number, $bloks_data[$row])){

        $bloks_data[$row][] = $number;

        if(sizeof($bloks_data[$row]) == $col_tnt && $i != $elements){
            $row++;
        }

        $i++;
        
    }
    $n++;
}

print_r($bloks_data);
HI-LO

PHP Version of the resulted HI-LO


$seed = hash_hmac('sha512', 'my server seed', 'my client seed'.':'.'my nonce');
$seed = hexdec(substr($seed,0,8));

$card_no = ($seed % 13) + 1;

echo $card_no;
Roulette Line

PHP Version of the resulted Roulette Line


  $seed = hash_hmac('sha512', 'my server seed', 'my client seed'.':'.'my nonce');
  $seed = hexdec(substr($seed,0,10));
  $roulette_number = $seed % 37;
  
  return $roulette_number;
Plinko

PHP Version of the resulted Plinko Game


$path = [];
        
$seed = hash_hmac(
        'sha512', 
$this->seeds[1].':'.$this->seeds[2], 
$this->seeds[0]
    );

$chars  = str_split($seed, 2);
$l      = sizeof($chars);

for ($i=0; $i<$l; $i+=4) {
$num = hexdec($chars[$i])/pow(256, 1) + hexdec($chars[$i+1])/pow(256, 2) + hexdec($chars[$i+2])/pow(256, 3) + hexdec($chars[$i+3])/pow(256, 4);
if($num < 0.5){
$path[] = 0;
        } else {
$path[] = 1;
        }
    }
    
echo $path;
Lottery

PHP Version of the resulted Lottery Game


$numbers = [];
$n = 0;
while(count($numbers) != 5){
  $seed = hash_hmac('sha512',$ss,'numbers-'.'last lottery id'.':'.$n);
  $seed = hexdec(substr($seed,0,10));
  $number = abs(substr(strval($seed),-4))%36 + 1;

  if(!in_array($number, $numbers)){
    $numbers[] = $number;
  }
  $n++;
}

$seed = hash_hmac('sha512',$ss,'jackpot:'.'last lottery id');
$seed = hexdec(substr($seed,0,10));
$jackpot = abs(substr(strval($seed),-4))%10 + 1;

print_r($numbers);
echo $jackpot;
Roulette EU

PHP Version of the resulted Roulette (EU)


  $seed = hash_hmac('sha512', 'my server seed', 'my client seed'.':'.'my nonce');
  $seed = hexdec(substr($seed,0,10));
  $roulette_number = $seed % 37;
  
  return $roulette_number;
Coin Flip

PHP Version of the resulted Coin Flip Game


$seed = hash_hmac('sha512', 'my server seed', 'my client seed'.':'.'my nonce');
$value = hexdec(substr($seed,0,8));

echo $value % 2;
Crash

PHP Version of the resulted Crash Game


const hash = crypto.createHmac("sha256", serverSeed).update(client_seed).digest("hex");

const hs = parseInt(100 / 5);
if (divisible(hash, hs)) {
  return 1;
}

const h = parseInt(hash.slice(0, 52 / 4), 16);
const e = Math.pow(2, 52);

let result = Math.floor((100 * e - h) / (e - h)) / 100.0;
console.log(result);