<?php
/*
* Fill in all four below and click the blue 'eval();' button.
* ------------------ */
$unhashedServerSeed = '';
$nonce = -1;
$clientSeed = '';
$qty = -1;
/* ------------------ */
if ($unhashedServerSeed == '' || $nonce < 0 || $clientSeed == '' || $qty <= 0) {
echo "Fill in details";
return;
}
define('MAX_HEX_SEGMENTS', 6);
define('HEX_SEGMENT_SIZE', 2);
define('BASE_FOR_HEX_CONVERSION', 256);
define('HASH_TYPE', 'sha256');
function calculateDecimalValue(string $preResult): float
{
$decimalValue = 0;
for ($i = 0; $i < MAX_HEX_SEGMENTS; $i++) {
$hexValue = substr($preResult, HEX_SEGMENT_SIZE * $i, HEX_SEGMENT_SIZE);
$decimalValue += hexdec($hexValue) / pow(BASE_FOR_HEX_CONVERSION, $i + 1);
}
return $decimalValue;
}
function getProvablyFairResult(string $init, int $qty): array
{
$preResult = hash(HASH_TYPE, $init);
$decimalValue = calculateDecimalValue($preResult);
$result = (int) ($decimalValue * $qty) + 1;
return [
'preResult' => $preResult,
'result' => $result,
];
}
$unhashedServerSeed = preg_replace( "/\r|\n/", "", $unhashedServerSeed);
$clientSeed = preg_replace( "/\r|\n/", "", $clientSeed);
$nrand = strlen($clientSeed);
$stringToHash = "$unhashedServerSeed-$clientSeed-$nrand-$nonce";
$result = getProvablyFairResult($stringToHash, $qty);
echo "Result: {$result['result']}";
- Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
- Fill in details
preferences:
57.49 ms | 406 KiB | 5 Q