Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,195,173 members, 7,957,382 topics. Date: Tuesday, 24 September 2024 at 11:48 AM |
Nairaland Forum / Science/Technology / Programming / Interprete This Javascript (635 Views)
HELP With This Javascript Problem / Can Someone Help Me With With This Javascript Exercise Please / Help Me With This Javascript Problem (2) (3) (4)
(1) (Reply)
Interprete This Javascript by Brukx(m): 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. |
(1) (Reply)
What Features Should A 2021 Forum Have? / What Do You Think About This Guys? My Latest Multi-purpose Site / Here Are Some Creative Ways You Can Money With Chat GPT
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 16 |