Files
  • index.js
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
 
//to verify -> copy your values and set seedObject as below:
var seedObject = {
  serverSeed: "1d26867264f68d6d1f503582dd6903ee", clientSeed: "42a00c71f192f75fca40fbf83b0cf8d3"};

verifyServerSeedvsHash(seedObject);

for(var i=1; i < 100; i++) {
  calcSeed(seedObject.serverSeed, seedObject.clientSeed, i);
}


function verifyServerSeedvsHash(seedObject) {
  var server_seed = seedObject.serverSeed;
    let hash = crypto.createHash('SHA256');
      hash.update(server_seed);
      var server_seed_hashed = hash.digest().toString('hex');
      console.log("server_seed: ", server_seed, "\nserver_seed_hashed: ", server_seed_hashed);
}

function calcSeed(server_seed, client_seed, nonce) {

      //var nonce = 1;
      var newclientseed = client_seed + "-" + nonce;
      //console.log("calcSeed newclientseed: ", newclientseed);

      let hmac = crypto.createHmac('SHA512', server_seed);
      hmac.update(newclientseed);
      let buf = hmac.digest();
      var finalOutput = buf.readUInt32BE() / Math.pow(2, 32) * 100;
      var winorlose = "lose";
      if(finalOutput < 45) {
        winorlose = "win";
      } 
      console.log("Bet Result: ",nonce, finalOutput, winorlose);
      return finalOutput;

}
node v10.15.2 linux/amd64