node-password-generator
Version:
A simple lightweight npm library for password generator. It allows you to create random unqiue password on the fly.
128 lines (74 loc) • 2.38 kB
Markdown
> Simple NPM library for generating random passwords.
```
$ npm install node-password-generator
```
```js
import { SimplePasswordGenerator } from 'node-password-generator';
const options = {
uppercase: true,
lowercase: false,
numbers: false,
symbols: false,
length: 10, //default
};
const generator = new SimplePasswordGenerator(options);
const password = generator.generatePassword();
console.log(password); //=> "YourPassword"
```
```js
import { WordsPasswordGenerator } from 'node-password-generator';
let filename = '/usr/share/dictionary.txt';
/*
Dictonary is plain txt file with random words
Aarhus
Aaron
Ababa
aback
abaft
abandon
abandoned
*/
const wordGenerator = new WordsPasswordGenerator({
filepath: filename,
wordcount: 3, //default word count is 3
separator: '_', //to join words default is empty string
});
const wordPassword = await wordGenerator.generatePassword();
console.log('wordPassword', wordPassword); //=> "random_password_generator"
```
Type: `Boolean | optional`
When true, the password will contain uppercase characters
Type: `Boolean | optional`
When true, the password will contain lowercase characters
Type: `Boolean | optional`
When true, the password will contain numeric characters
Type: `Boolean | optional`
When true, the password will contain special characters
Type: `Number | optional`
Default password length is 10, but it can be override by giving integer value.
Type: `String | required`
Complete file path of dictonary file
Type: `wordcount | optional`
Default word length is 3, & Minimum length is 1, but it can be override by giving integer value.
Type: `string | optional`
To join multiple words, Default separator is empty string, but it can be override by giving character/string value.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
[](https://choosealicense.com/licenses/mit/)