1.3.0 • Published 11 months ago
randomstring v1.3.0
node-randomstring
Library to help you create random strings.
Installation
To install randomstring, use npm:
npm install randomstring
Usage
var randomstring = require("randomstring");
randomstring.generate();
// >> "XwPp9xazJ0ku5CZnlmgAx2Dld8SHkAeT"
randomstring.generate(7);
// >> "xqm5wXX"
randomstring.generate({
length: 12,
charset: 'alphabetic'
});
// >> "AqoTIzKurxJi"
randomstring.generate({
charset: 'abc'
});
// >> "accbaabbbbcccbccccaacacbbcbbcbbc"
randomstring.generate({
charset: ['numeric', '!']
});
// >> "145132!87663611567!2486211!07856"
randomstring.generate({
charset: 'abc'
}, cb);
// >> "cb(generatedString) {}"
API
randomstring.
generate(options, cb)
options
length
- the length of the random string. (default: 32) OPTIONALreadable
- exclude poorly readable chars: 0OIl. (default: false) OPTIONALcharset
- define the character set for the string. (default: 'alphanumeric') OPTIONALcapitalization
- define whether the output should be lowercase / uppercase only. (default: null) OPTIONALlowercase
uppercase
cb
- Optional. If provided uses async version ofcrypto.randombytes
Command Line Usage
$ npm install -g randomstring
$ randomstring
> sKCx49VgtHZ59bJOTLcU0Gr06ogUnDJi
$ randomstring 7
> CpMg433
$ randomstring length=24 charset=github readable
> hthbtgiguihgbuttuutubugg
Tests
npm install
npm test
LICENSE
node-randomstring is licensed under the MIT license.
1.3.0
11 months ago
1.2.3
2 years ago
1.2.2
2 years ago
1.2.0
3 years ago
1.2.1
3 years ago
1.1.5
8 years ago
1.1.4
8 years ago
1.1.3
8 years ago
1.1.2
8 years ago
1.1.0
9 years ago
1.0.8
9 years ago
1.0.7
9 years ago
1.0.6
9 years ago
1.0.5
9 years ago
1.0.4
9 years ago
1.0.3
10 years ago
1.0.2
12 years ago
1.0.1
12 years ago
1.0.0
12 years ago