Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*MasterBugPatch
- Feel free to send me bits ;) https://www.bustabit.com/user/masterbugpatch
- */
- function runCheck(){
- var gamesToCheck = parseInt(document.getElementById("gamesInput").value);
- var hash = document.getElementById("hashInput").value;
- var crashToCheck = parseInt(document.getElementById("crashInput").value);
- var intervalsBetweenCrashes = [];
- var waitingForFirstCrash = true;
- var gamesTillCrash = 0;
- var mostRecentCrash = 0;
- for(var n = 0; n != gamesToCheck;n++){
- var gameCrash = crashPointFromHash(hash);
- if(gameCrash >= crashToCheck){
- if(waitingForFirstCrash){
- waitingForFirstCrash = false;
- mostRecentCrash = gamesTillCrash;
- }else{
- intervalsBetweenCrashes.push(gamesTillCrash);
- }
- gamesTillCrash = 0;
- }else{
- gamesTillCrash++;
- }
- hash = genGameHash(hash);
- }
- var result = "Last " + crashToCheck + "x occured " + mostRecentCrash + " games from the hash<br>Intervals between " + crashToCheck + "x crashes within last " + gamesToCheck + " games below..." + "<br>" + intervalsBetweenCrashes;
- document.getElementById("status").innerHTML = result;
- }
- function requestCheck(){
- document.getElementById("status").innerHTML = "Checking...";
- setTimeout(runCheck, 0);
- }
- /*ALL CODE BELOW THIS LINE IS FROM https://jsfiddle.net/1L1uqcgv/6/embedded/result/*/
- function divisible(hash, mod) {
- 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);
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement