- Account
- Next Seed Hash
- Revealed Seed
- Spin Result
#!/usr/bin/env node
const crypto = require("crypto");
class LuckyNumberGenerator {
selectNumber(payload, secret) {
const hmac = cryptolib
.createHmac("sha512", payload)
.update(secret)
.digest("hex");
let f7 = hmac.substring(0, 7);
let int = parseInt(f7, 16);
let number = this.reduce(int, 1, 12);
return number;
}
// use to reduce a number to appropriate size
reduce = (number, outMin, outMax) =>
(number % ((outMax - outMin) + 1)) + outMin;
}
// const luckyNumbersGenerator = new LuckyNumberGenerator();
// const uid = '';
// const secret = '';
// const luckyNumber = luckyNumbersGenerator.selectNumber(uid, secret);
// console.log(luckyNumber); === undefined