npm i sos-password-generator
- Require the package:
const PasswordGenerator = require('sos-password-generator')
- Create an instance of PowerGenerator Class
const generator = new PasswordGenerator();
- Generate your password:
console.log(generator.generatePassword()); //Result => generates random 8-character-length password
// contains numbers,lower case ,upper case, and symbols.
Before generating password,You can pass options object to the method init
generator.init({
hasUpper:true,
hasLower:true,
hasSymbol:true,
hasNumber:false,
passwordLength:15,
allowedSymbols: '!@#$',
})
hasUpper:true
hasLower:true
hasSymbol:true
hasNumber:true
passwordLength:8
allowedSymbols: '!@#$%^&*(){}[]=/<>,.'