advanced-password-generator
v1.2.0
Published
This advanced password generator creates customizable passwords with lowercase letters, uppercase letters, numbers, symbols, and hyphens. It can also generate Apple-style passwords (20 characters long) and assess password strength.
Downloads
70
Maintainers
Readme
Advanced Password Generator
- This advanced password generator creates customizable passwords with lowercase letters, uppercase letters, numbers, symbols, and hyphens. It can also generate Apple-style passwords (20 characters long) and assess password strength.
Updates
- New option: When the
apple
option is enabled, the function generates Apple-style passwords. These passwords are 20 characters long and include 16 lowercase letters, 1 uppercase letter, 1 number, and 2 hyphens.
Features
Generate passwords with:
- Lowercase letters (optional)
- Uppercase letters (optional)
- Numbers (optional)
- Symbols (optional)
- Hyphens (optional)
- Apple (optional)
Usage
Function Definition
options
: An object specifying which types of characters to include in the password and whether to check password strength.totalLength
: The total length of the generated password.
Options
The options
parameter is an object with the following properties:
lowercase
: (boolean) Include lowercase letters in the password.uppercase
: (boolean) Include uppercase letters in the password.numbers
: (boolean) Include numbers in the password.symbols
: (boolean) Include symbols in the password.hyphens
: (boolean) Include hyphens (-
) every 6 characters.apple
: (boolean) Generate a password in the style of Apple Password Generator, which is 20 characters long and includes 16 lowercase letters, 1 uppercase letter, 1 number, and 2 hyphens positioned after the 6th and 12th characters.checkStrength
: (boolean) Enables password strength evaluation based on length, character variety (lowercase, uppercase, numbers, symbols). Returns a strength assessment (e.g., Very Weak to Strong)
Example Usages
- Example 1: Generate Apple-style password
var generatePassword = require('advanced-password-generator');
var options = {
apple: true,
checkStrength: true
};
var totalLength = 20;
var generatedPassword = generatePassword(totalLength, options);
console.log("Generated a password in the style of Apple Password Generator:", generatedPassword);
//Example output: lxogiW-sbv9cv-jxmnzk, Password strength: Strong
- Example 2: Lowercase Letters Only
var generatePassword = require('advanced-password-generator');
var options = {
lowercase: true,
uppercase: false,
numbers: false,
symbols: false,
hyphens: false,
apple: false,
checkStrength: true
};
var totalLength = 10;
var generatedPassword = generatePassword(totalLength, options);
console.log("Generated password (lowercase only):", generatedPassword);
//Example output: bpjjkriydb, Password strength: Very Weak
This will generate a password with 10 lowercase letters.
- Example 3: Mixed Characters with Hyphens
var generatePassword = require('advanced-password-generator');
var options = {
lowercase: true,
uppercase: true,
numbers: true,
symbols: false,
hyphens: true,
apple: false,
checkStrength: false
};
var totalLength = 20;
var generatedPassword = generatePassword(totalLength, options);
console.log("Generated password (uppercase and lowercase letters, numbers, hyphens):", generatedPassword);
//Example output: hNfVdL-ZWnYH4-p2UaCb
This will generate a password with 20 characters that include uppercase letters, lowercase letters, numbers and hyphens for better readability.
- Example 4: Mixed Characters with Default Options
var generatePassword = require('advanced-password-generator');
var totalLength = 20;
var generatedPassword = generatePassword(totalLength);
console.log("Generated password with Default Options:", generatedPassword);
// Example output: fxP2O1-kw5aJ6-2KydFB
This will generate a password with 20 characters that include uppercase letters, lowercase letters, numbers, and hyphens for better readability. If no options
are specified, the function will use the following defaults:
options = {
lowercase: true,
uppercase: true,
numbers: true,
symbols: false,
hyphens: true,
apple: false,
checkStrength: false
};
This means you do not need to specify the options unless you want to customize them.
Notes
- If both
lowercase
anduppercase
are set totrue
, the password will include both uppercase and lowercase letters. - When
hyphens
is selected, the total length will include the hyphens, so the actual character count will be adjusted accordingly. - For Apple-style passwords, the total length cannot be changeable because Apple-style passwords are always 20 characters long.
License
Discord
- Do you have a suggestion or complaint? Feel free to reach me on Discord with the nickname Ervel