0% found this document useful (0 votes)
91 views1 page

Script

The document initializes values from URL parameters for server_seed, client_seed, server_seed_hash, and nonce using decodeURIComponent. It defines a click handler for the #verify button that calculates a hashed value from the seeds and nonce, extracts the first 8 characters to generate a random number, and checks if the server_seed_hash matches the calculated hash, displaying the result.

Uploaded by

Semih Öztürk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
91 views1 page

Script

The document initializes values from URL parameters for server_seed, client_seed, server_seed_hash, and nonce using decodeURIComponent. It defines a click handler for the #verify button that calculates a hashed value from the seeds and nonce, extracts the first 8 characters to generate a random number, and checks if the server_seed_hash matches the calculated hash, displaying the result.

Uploaded by

Semih Öztürk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

$(document).

ready(function()
{
$
('#server_seed').val(decodeURIComponent($.urlParam('server_seed')));
$
('#client_seed').val(decodeURIComponent($.urlParam('client_seed')));
$
('#server_seed_hash').val(decodeURIComponent($.urlParam('server_seed_hash')));
$('#nonce').val(decodeURIComponent($.urlParam('nonce')));
$("#verify").click(function(event)
{
var server_seed = $('#server_seed').val();
var client_seed = $('#client_seed').val();
var nonce = $('#nonce').val();
var server_seed_hash =
CryptoJS.SHA256(server_seed).toString(CryptoJS.enc.Hex);
var string1 =
nonce.concat(":",server_seed,":",nonce);
var string2 =
nonce.concat(":",client_seed,":",nonce);
var hmac512 =
CryptoJS.HmacSHA512(string1,string2).toString(CryptoJS.enc.Hex);
var string3 = hmac512.substring(0,8);
var number = parseInt(string3, 16);
var roll =
(Math.round(number/429496.7295)).toFixed(0);
$('#rolled_number').html(roll);
if ($('#server_seed_hash').val() == server_seed_hash)
{
$('#verify_server_seed_hash_msg').html("<font
color=green>SERVER SEED HASH MATCHES</font>");
}
else
{
$('#verify_server_seed_hash_msg').html("<font
color=red>SERVER SEED HASH DOES NOT MATCH</font>");
}
});
});
$.urlParam = function(name)
{
var results = new RegExp('[\?&]' + name +
'=([^&#]*)').exec(window.location.href);
if (results==null){
return '';
}
else{
return results[1] || 0;
}
}

You might also like