A package for generating secure passwords and estimating the time required to crack them.
npm install password-guardian
Generates a secure password based on the provided options.
-
options
(object):-
length
(number, optional): Length of the password (default is 10). -
includeNumbers
(boolean, optional): Include numbers in the password (default is true). -
includeUppercase
(boolean, optional): Include uppercase letters in the password (default is true). -
includeLowercase
(boolean, optional): Include lowercase letters in the password (default is true). -
includeSpecialChars
(boolean, optional): Include special characters in the password (default is true). -
customWord
(string, optional): A custom word to include in the password (default is empty string). -
customWordPosition
(string, optional): Position of the custom word ('start'
,'end'
, or'anywhere'
) (default is'start'
).
-
const { generateSecurePassword } = require('password-guardian');
const password = generateSecurePassword({
length: 12,
includeNumbers: true,
includeUppercase: true,
includeLowercase: true,
includeSpecialChars: false,
customWord: 'max',
customWordPosition: 'end'
});
console.log(password);
Estimates the time required to crack a password based on the number of guesses per second.
-
password
(string): The password to estimate crack time for. -
guessesPerSecond
(number): The estimated number of guesses a computer can make per second.
const { estimateCrackTime } = require('password-guardian');
const password = 'MySecurePassword123!';
const guessesPerSecond = 1000000; // Example guess rate
const crackTime = estimateCrackTime(password, guessesPerSecond);
console.log(`It would take approximately ${crackTime} to crack this password.`);