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) {