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";