@cityssm/simple-password-generator
v2.1.2
Published
Makes generating simple or complex, appropriate passwords a breeze.
Downloads
245
Maintainers
Readme
simple-password-generator
Makes generating simple or complex, appropriate passwords a breeze.
Passwords can have a minimum or maximum length.
Passwords can include words, letters, numbers, and symbols.
Passwords are scanned with zxcvbn-typescript to reduce their guessability.
Passwords are translated with unleet, and scanned using badwords to make sure they are appropriate.
Installation
npm install @cityssm/simple-password-generator
Usage
import { generatePassword } from "@cityssm/simple-password-generator";
generatePassword();
= "carPoetDRIVING%38"
generatePassword({ minLength: 15, pattern: "wnWnX" });
= "curious6COMPOSITION7B"
generatePassword({ pattern: 'xxxXXXnnns', doShufflePattern: true });
= "c0O4WG@od9"
Options
| Option | Description | Default |
| ---------------- | ------------------------------------------------------------------------------------------------------- | -------- |
| minLength | The minimum password length. | 8
|
| maxLength | The maximum password length. | 50
|
| pattern | The format the password should use. | "wCnn"
|
| doShufflePattern | Whether the pattern should be ordered randomly or not. | false
|
| minScore | The minimum allowable zxcvbn guessability score, where 0 is "too guessable" and 4 is "very unguessable" | 2
|
| retries | The number of times the generator should try to generate a password before failing and returning null. | 20
|
Note that if your pattern
cannot generate a password
within your set minLength
and maxLength
,
the generatePassword()
function may return a null
value.
Pattern Options
| Pattern Character | Description | Example | | ----------------- | ----------------- | ------- | | w | Lower case word | word | | W | Upper case word | WORD | | C | Capitalized word | Word | | x | Lower case letter | a | | X | Upper case letter | A | | n | Number | 9 | | s | Symbol | @ |