Check if the password is strong.
Here an example of a strong password check:
var strongPasswordValidation = new StrongPassword({
password: 'This is 1 strong password!',
locale: 'en_US'
});
console.log(strongPasswordValidation.isStrong);
Here an example of a weak password check:
var strongPasswordValidation = new StrongPassword({
password: 'Not strong',
locale: 'en_US'
});
console.log(strongPasswordValidation.isStrong);
console.log(strongPasswordValidation.reason);
- password
- locale ('en_US')
- minimumLength (10)
- minimumWords (4)
- numbers (true)
- lowercase (true)
- uppercase (uppercase)
- dictionaries (typo/dictionaries)
- specials (/[,.?!]/g)
Only the password param is required. For the other params you see the default value in the list.
With this param you can set the dictionary for the words. This will check if you only use normal words, so you can remember it.
With this param you can set the minimum length of the password. The default length is a total of 10 chars, including spaces.
With this param you can set the minimum words in the password. The default length is a total of 4 words, so the password is long, and not easy to guess.
With this param you can set that the password must have a number.
With this param you can set that the password must have a alphabetical lowercase char.
With this param you can set that the password must have a alphabetical uppercase char.
You can add another dictionary than en_US.
You can define the specials that will be ignored in the words.
npm test
This will run all the tests in the test folder with mocha.
If you only want to check the eslint rules, just run.
npm run lint
To include strongpassword in Node, first install with npm.
npm install strongpassword
Use the package in your node files.
require('strongpassword');