1.3.1 • Published 5 months ago
randomstring v1.3.1
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.1
5 months ago
1.3.0
2 years ago
1.2.3
3 years ago
1.2.2
3 years ago
1.2.0
4 years ago
1.2.1
4 years ago
1.1.5
9 years ago
1.1.4
9 years ago
1.1.3
10 years ago
1.1.2
10 years ago
1.1.0
10 years ago
1.0.8
10 years ago
1.0.7
10 years ago
1.0.6
10 years ago
1.0.5
10 years ago
1.0.4
10 years ago
1.0.3
11 years ago
1.0.2
13 years ago
1.0.1
13 years ago
1.0.0
13 years ago