2.1.2 • Published 7 years ago
rand-password-gen v2.1.2
#rand-password-gen A simple, random and secure password generator for Node.js and browsers.
Installation
$ npm install rand-password-gen
$ npm test
Usage
from the browser
var password = require('rand-password-gen');
var myNewPassword = password({length: 16});
// -> e.g. xc00K8196#>2LS\Y
Customize by passing array of characters to exclude from password.
var password = require('rand-password-gen');
var options = {
length: 16,
exclusions: ['(', '0','o', 'O', ')', '~', '\\', '/', '|', '}', '{', '[', ']', 'l', '1']
};
var myNewPassword = password(options);
// -> e.g. Yk>N*ZCktFizQ_ZN
Customize by passing array of inclusion rules.
var password = require('rand-password-gen');
var charRange = require('rand-password-gen/src/util/genAsciiCharRangeArr');
var options = {
length: 19,
exclusions: ['(', '0','o', 'O', ')', '~', '\\', '/', '|', '}', '{', '[', ']', 'l', '1', '2', '3', 'a', 'b', 'C'],
inclusionRules: [
// password must include at least 3 upper-case letters
{
minNumChars: 3,
charSet: 'UPPERCASE',
},
// password must include at least 3 lower-case letters
{
minNumChars: 3,
charSet: 'LOWERCASE',
},
// password must include at least 1 number
{
minNumChars: 1,
charSet: 'SPECIAL_CHAR'
}
]
};
var myNewPassword = password(options);
// -> e.g. ;q4K=^fNUFJe#jEGjw4
options Object.
var options = {
// *number* - length of password
length: 18,
// *Array* - characters to exclude from password
exclusions: ['(', '0','o', 'O', ')'],
// *Array* - of objects that describe the inclusions rules, i.e. must have 3 upper-case letters
inclusionRules:
[
// *Object*
{
// *number* - minimum number of characters of this set in password
minNumChars: 3,
// *Array* - characters randomly selected from this set for rule
// 'UPPERCASE' | 'LOWERCASE' | 'DIGIT' | 'SPECIAL_CHAR'
charSet: 'UPPERCASE',
}
]
};
Running tests
Install dev dependencies:
$ npm install && npm test
Author
Andy Coles
License
Copyright © 2017, Andy Coles. Released under the MIT License.