查看此jsfiddle:https://jsfiddle.net/1L1uqcgv/6/?utm_source=website&utm_medium=embed&utm_campaign=1L1uqcgv
function refreshTable(){
var hash = document.getElementById("gameHash").value;
var lastHash = "";
var amount = document.getElementById("gameAmount").value;
var tableBody = document.getElementById("tbody");
tableBody.innerHTML = "";
for(var i=0; i<amount; i++){
var gameHash = (lastHash!=""?genGameHash(lastHash):hash);
var gameCrash = crashPointFromHash((lastHash!=""?genGameHash(lastHash):hash));
var clr = gameCrash > 1.97 ? 'green': (gameCrash < 1.97 ? 'red' : 'blue');
tableBody.innerHTML += "<tr><td>"+gameHash+"</td><td style='background:" + clr + "'>"+gameCrash+"</td></tr>";
lastHash = gameHash;
}
}
function divisible(hash, mod) {
// So ABCDEFGHIJ should be chunked like AB CDEF GHIJ
var val = 0;
var o = hash.length % 4;
for (var i = o > 0 ? o - 4 : 0; i < hash.length; i += 4) {
val = ((val << 16) + parseInt(hash.substring(i, i+4), 16)) % mod;
}
return val === 0;
}
function genGameHash(serverSeed) {
return CryptoJS.SHA256(serverSeed).toString()
};
function hmac(key, v) {
var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
return hmacHasher.finalize(v).toString();
}
function crashPointFromHash(serverSeed) {
// see: provably fair seeding event
var hash = hmac(serverSeed, '000000000000000007a9a31ff7f07463d91af6b5454241d5faf282e5e0fe1b3a');
// In 1 of 101 games the game crashes instantly.
if (divisible(hash, 101))
return 0;
// Use the most significant 52-bit from the hash to calculate the crash point
var h = parseInt(hash.slice(0,52/4),16);
var e = Math.pow(2,52);
return (Math.floor((100 * e - h) / (e - h))/100).toFixed(2);
};
是否可以找到第31和41行所示的“serverSeed”? 为了找到以前的游戏,在框中输入一个哈希,显示所有以前的游戏。 serverSeed会用于查找这些哈希值,还是单个哈希值会创建所有以前的哈希值?
答案 0 :(得分:0)
ServerSeed是您输入的哈希值,用于查看崩溃点并查看之前的游戏。