You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

1 lines
848 B

{"ast":null,"code":"'use strict';\n/* global crypto:true */\n\nvar crypto = require('crypto'); // This string has length 32, a power of 2, so the modulus doesn't introduce a\n// bias.\n\n\nvar _randomStringChars = 'abcdefghijklmnopqrstuvwxyz012345';\nmodule.exports = {\n string: function (length) {\n var max = _randomStringChars.length;\n var bytes = crypto.randomBytes(length);\n var ret = [];\n\n for (var i = 0; i < length; i++) {\n ret.push(_randomStringChars.substr(bytes[i] % max, 1));\n }\n\n return ret.join('');\n },\n number: function (max) {\n return Math.floor(Math.random() * max);\n },\n numberString: function (max) {\n var t = ('' + (max - 1)).length;\n var p = new Array(t + 1).join('0');\n return (p + this.number(max)).slice(-t);\n }\n};","map":null,"metadata":{},"sourceType":"script"}