<?php
/*
* Fill in all five below and click blue 'eval();' button below textarea.
*
* ------------------ */
$caseNumber = -1;
$unhashedServerSeed = '';
$nonce = -1;
$clientSeed = '';
$qty = -1;
/* ------------------ */
if ($caseNumber < 0 || $unhashedServerSeed == '' || $nonce < 0 || $clientSeed == '' || $qty < 0) {
echo "Fill in details";
return;
}
$unhashedServerSeed = preg_replace( "/\r|\n/", "", $unhashedServerSeed );
$clientSeed = preg_replace( "/\r|\n/", "", $clientSeed );
function calculatePreResult($init, $depth, $numIterations = 0, $hash = null)
{
if ($numIterations === $depth) {
return $hash;
}
if ($numIterations === 0) {
$hash = $init;
}
return calculatePreResult($init, $depth, $numIterations + 1, hash('sha256', $hash));
}
$preResult = calculatePreResult("$unhashedServerSeed-$clientSeed-$caseNumber-$nonce", 1000);
$preResultAsInt = hexdec(substr(bin2hex($preResult), 0, 8));
$result = ($preResultAsInt % $qty) + 1;
echo "Pre-Result: $preResult / $preResultAsInt\n";
echo "Result: $result";
preferences:
26.46 ms | 408 KiB | 5 Q