abrupt
Version:
(Random - Strings, Numbers, Booleans, Floats, Objects, Arrays) (Crypto - Base64, AES, RSA, MD5, SHA512, Morse, Rot13)
15 lines (13 loc) • 463 B
JavaScript
const randint = require("./int.js")
const randobject = require("./object.js")
let alpha = {}
for (let i = 97; i <= 122; i++) alpha[i-97] = String.fromCharCode(i)
module.exports = (len, alphabet) => {
const isBool = ((typeof len == "boolean") && (len))
if ((isBool) || (!len)) len = 5
let s = ""
for (let i = 1; i <= len; i++) {
s += ((alphabet) || (isBool)) ? randobject(alpha) : String.fromCharCode(randint(33,126))
}
return s
}