1.1.7 • Published 4 years ago
@d-fischer/randomstring v1.1.7
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"
API
randomstring.
generate(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') OPTIONALalphanumeric
- 0-9 a-z A-Zalphabetic
- a-z A-Znumeric
- 0-9hex
- 0-9 a-fcustom
- any given characters
capitalization
- define whether the output should be lowercase / uppercase only. (default: null) OPTIONALlowercase
uppercase
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.