@citlayik/

tcmverify

Nodejs

No description

fork
loading
Files
  • index.js

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.9456520357948821","path":"index.js","file":{"path":"index.js","content":{"asEncoding":{"base64":"IAovL3RvIHZlcmlmeSAtPiBjb3B5IHlvdXIgdmFsdWVzIGFuZCBzZXQgc2VlZE9iamVjdCBhcyBiZWxvdzoKdmFyIHNlZWRPYmplY3QgPSB7CiAgc2VydmVyU2VlZDogIjFkMjY4NjcyNjRmNjhkNmQxZjUwMzU4MmRkNjkwM2VlIiwgY2xpZW50U2VlZDogIjQyYTAwYzcxZjE5MmY3NWZjYTQwZmJmODNiMGNmOGQzIn07Cgp2ZXJpZnlTZXJ2ZXJTZWVkdnNIYXNoKHNlZWRPYmplY3QpOwoKZm9yKHZhciBpPTE7IGkgPCAxMDA7IGkrKykgewogIGNhbGNTZWVkKHNlZWRPYmplY3Quc2VydmVyU2VlZCwgc2VlZE9iamVjdC5jbGllbnRTZWVkLCBpKTsKfQoKCmZ1bmN0aW9uIHZlcmlmeVNlcnZlclNlZWR2c0hhc2goc2VlZE9iamVjdCkgewogIHZhciBzZXJ2ZXJfc2VlZCA9IHNlZWRPYmplY3Quc2VydmVyU2VlZDsKICAgIGxldCBoYXNoID0gY3J5cHRvLmNyZWF0ZUhhc2goJ1NIQTI1NicpOwogICAgICBoYXNoLnVwZGF0ZShzZXJ2ZXJfc2VlZCk7CiAgICAgIHZhciBzZXJ2ZXJfc2VlZF9oYXNoZWQgPSBoYXNoLmRpZ2VzdCgpLnRvU3RyaW5nKCdoZXgnKTsKICAgICAgY29uc29sZS5sb2coInNlcnZlcl9zZWVkOiAiLCBzZXJ2ZXJfc2VlZCwgIlxuc2VydmVyX3NlZWRfaGFzaGVkOiAiLCBzZXJ2ZXJfc2VlZF9oYXNoZWQpOwp9CgpmdW5jdGlvbiBjYWxjU2VlZChzZXJ2ZXJfc2VlZCwgY2xpZW50X3NlZWQsIG5vbmNlKSB7CgogICAgICAvL3ZhciBub25jZSA9IDE7CiAgICAgIHZhciBuZXdjbGllbnRzZWVkID0gY2xpZW50X3NlZWQgKyAiLSIgKyBub25jZTsKICAgICAgLy9jb25zb2xlLmxvZygiY2FsY1NlZWQgbmV3Y2xpZW50c2VlZDogIiwgbmV3Y2xpZW50c2VlZCk7CgogICAgICBsZXQgaG1hYyA9IGNyeXB0by5jcmVhdGVIbWFjKCdTSEE1MTInLCBzZXJ2ZXJfc2VlZCk7CiAgICAgIGhtYWMudXBkYXRlKG5ld2NsaWVudHNlZWQpOwogICAgICBsZXQgYnVmID0gaG1hYy5kaWdlc3QoKTsKICAgICAgdmFyIGZpbmFsT3V0cHV0ID0gYnVmLnJlYWRVSW50MzJCRSgpIC8gTWF0aC5wb3coMiwgMzIpICogMTAwOwogICAgICB2YXIgd2lub3Jsb3NlID0gImxvc2UiOwogICAgICBpZihmaW5hbE91dHB1dCA8IDQ1KSB7CiAgICAgICAgd2lub3Jsb3NlID0gIndpbiI7CiAgICAgIH0gCiAgICAgIGNvbnNvbGUubG9nKCJCZXQgUmVzdWx0OiAiLG5vbmNlLCBmaW5hbE91dHB1dCwgd2lub3Jsb3NlKTsKICAgICAgcmV0dXJuIGZpbmFsT3V0cHV0OwoKfQ=="},"asBuffer":null},"loaded":true}}
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.16.0