const crypto = require("crypto");

// COPY AND PASTE from dejen.com
const clientSeed = "DegenApe";
const serverSeed = "bde86302c03e224d6ebbcfb22f513a017fabd839";
const nonce = 5;
// THEN press Run |> 


const roll = getRoll(serverSeed, clientSeed, nonce);

console.log(`Roll: ${roll}`);


function getRoll(serverSeed, clientSeed, nonce) {
  const seed = `${serverSeed}-${clientSeed}-${nonce}`;
  const hash = crypto.createHmac("sha256", seed).digest("hex");
  const subHash = hash.substring(0, 8);
  const number = Number.parseInt(subHash, 16);
  return 1 + (Math.abs(number) % 1000000);
}