From 66d5fa1b84167e88272f4a573dee17f7d510ba61 Mon Sep 17 00:00:00 2001 From: cardinal9999 <86199598+cardinal9999@users.noreply.github.com> Date: Tue, 31 Aug 2021 21:49:51 -0400 Subject: [PATCH] Update random.js --- javascript/random.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/javascript/random.js b/javascript/random.js index c6d5936..04cd270 100644 --- a/javascript/random.js +++ b/javascript/random.js @@ -1,25 +1,25 @@ var cryptoObj; cryptoObj = window.crypto || window.msCrypto; -var randbelow; -randbelow = function(max) { + +export function randbelow(max) { array = new Uint16Array(4); cryptoObj.getRandomValues(array); eeeeee = array[0] * array[1] * array[2]; return eeeeee % max; } -var randint; -randint = function(min, max) { + +export function randint(min, max) { x = max - min; distance = randbelow(x); return max - distance; } -var choice; -choice = function(group) { + +export function choice(group) { return group[randbelow(group.length)]; } -var token_alphanumeric; -token_alphanumeric = function(length) { + +export function alphanumeric(length) { var str = ""; for(var i = 0; i < length; ++i){ chars = "qazwsxedcrfvtgbyhnujmikolpQAZWSXEDCRFVTGBYHNUJMIKOLP1234567890";