randstring

random strings

npm install randstring
8 downloads in the last month

randstring

randstring generates pseudorandom strings.

randstring(len)

generates a random string with the default charset '0123456789abcdefghijklmnopqrstuvwxyz' and the given length.

var randstring = require('randstring');
console.log(randstring(50));

output:

t25rlupqia7n7295rwo5pohgfrmf68tm91p4enu8lqk3y7wygp

randstring.withCharset(charset, len)

generates a random string with the given charset and length.

var randstring = require('randstring');
console.log(randstring.withCharset('abc',50));

output:

babbababbabbaababbabbaababaabaabbbbbaaabbaaabababa

randstring.withCharset(charset)

returns a partially applied randstring.withCharset(charset, len)

var randstring = require('randstring');
var abcstring = randstring.withCharset('abc');
console.log(abcstring(50));

output:

aaaaaabbbbabaabbabaababbbbaabbaabaaabbabababbbaaaa

randstring.randrange(max)

internal function. generates a number in the range [0,max]. replace it for more randomness.

npm loves you