From a930806c9f856dcc2c84f7abc8c0ac804d987c64 Mon Sep 17 00:00:00 2001 From: cardinal9999 <86199598+cardinal9999@users.noreply.github.com> Date: Tue, 31 Aug 2021 22:00:10 -0400 Subject: [PATCH] Update random.js --- javascript/random.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/javascript/random.js b/javascript/random.js index 04cd270..b4ca6e3 100644 --- a/javascript/random.js +++ b/javascript/random.js @@ -1,22 +1,22 @@ var cryptoObj; cryptoObj = window.crypto || window.msCrypto; - -export function randbelow(max) { - array = new Uint16Array(4); - cryptoObj.getRandomValues(array); - eeeeee = array[0] * array[1] * array[2]; - return eeeeee % max; - } +function randbelow(max) { + array = new Uint16Array(7); + cryptoObj.getRandomValues(array); + N = array[0] + array[1]; + O = array[2] * array[5]; + return (N * O) % max +} export function randint(min, max) { - x = max - min; - distance = randbelow(x); - return max - distance; + x = max - min; + distance = randbelow(x); + return max - distance; } export function choice(group) { - return group[randbelow(group.length)]; + return group[randbelow(group.length)]; } export function alphanumeric(length) {