Interprete This Javascript - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Interprete This Javascript (697 Views)
1 Reply
| Interprete This Javascript by Brukx(op): 5:36pm On Jun 20, 2020 |
The script below are the instructions an online casino uses in generating random floats. I don't understand J's, but with my knowledge of python I have an idea what's going on in the script except for the hashing (SHA512) part. Anyone with good js knowledge should come tell us what's happening here // fill client seed, server seed and nonce with values from your roll details: const clientSeed = "ZOujisvXvVe7fBedsQkWQaHwi5GiBFTz"; const serverSeed = "Wgh5dqFCnKihl07hluONRzs8wkDJSaBMuAwuviWNlQjPrFsonsYYNe0irlz0ld00"; const nonce = 127; console.log(roll(serverSeed, clientSeed, nonce)); // ------------ don't edit below this line ------------ function roll(serverSeed, clientSeed, nonce) { const crypto = require('crypto'); const text = clientSeed + ':' + nonce; const hash = crypto.createHmac('sha512', serverSeed).update(text).digest('hex'); const hashLength = hash.length; const step = 5; let index = 0; let rollResult; do { const start = index * step; const end = start + step; if (end > hashLength) { rollResult = 9999; break; } rollResult = parseInt(hash.substring(start, end), 16); index++; } while (rollResult >= Math.pow(10, 6)); rollResult %= Math.pow(10, 4); rollResult /= Math.pow(10, 2); return rollResult; } |
| Re: Interprete This Javascript by Edipet(m): 6:55pm On May 25, 2023 |
Brukx:omor. Looks like something that vi should know but I don't know it |
| Re: Interprete This Javascript by niel63(m): 9:49pm On May 25, 2023 |
Js is an interpreted language. ![]() Wetin we wan interprete again? Everything you see there is as it is... literally in plain language. Abi na the modulo dey consfuse you? The conditionals or the crypto package and its methods? The place they said dont edit, no mind them. You can edit the to your choice of naming except for some of the reserved keywords and method. |
HELP With This Javascript Problem • Can Someone Help Me With With This Javascript Exercise Please • Help Me With This Javascript Problem • 2 • 3 • 4
[2025] EFT Pro Tool Activation Without Dongle • Free Online Converter Helps You Convert Videos Easily • Reviews On NIIT Abuja
