1.1.2 • Published 5 years ago

strict-password-generator v1.1.2

Weekly downloads
820
License
MIT
Repository
github
Last release
5 years ago

strict-password-generator

Generate a random password with strict requirements

Install

$ npm install strict-password-generator --save

Usage

const PasswordGenerator = require('strict-password-generator').default;

const passwordGenerator = new PasswordGenerator();

// return value is a unique randomly generated password string
let password = passwordGenerator.generatePassword();

Options

Pass options object to passwordGenerator.generatePassword()

Possible special characters : '!', '@', '#', '$', '%', '^', '*', '+', '_', '-', '=', ':', ';', '?'

NameTypeDefault Value
upperCaseAlphaBooltrue
lowerCaseAlphaBooltrue
numberBooltrue
specialCharacterBooltrue
minimumLengthInt (Must be >= 4)8
maximumLengthIntminimumLength + 4
exactLengthIntnone

Examples

const PasswordGenerator = require('strict-password-generator').default;

const passwordGenerator = new PasswordGenerator();

const options = {
  upperCaseAlpha   : false,
  lowerCaseAlpha   : true,
  number           : true,
  specialCharacter : false,
  minimumLength    : 10,
  maximumLength    : 12
}

let password = passwordGenerator.generatePassword(options);

console.log(password); // example string : qa5859qoz8

const PasswordGenerator = require('strict-password-generator').default;

const passwordGenerator = new PasswordGenerator();

// exactLength will always override minimumLength and maximumLength
const options = {
  minimumLength    : 10,
  maximumLength    : 12,
  exactLength      : 15   
}

let password = passwordGenerator.generatePassword(options);

console.log(password); // example string : 5eT1c^n9,`35C5}