password-guardian
v1.0.4
Published
A versatile npm package for generating secure passwords and estimating the time required for computer-based cracking.
Downloads
5
Maintainers
Readme
password-guardian
A package for generating secure passwords and estimating the time required to crack them.
Installation
npm install password-guardian
generateSecurePassword(options)
Generates a secure password based on the provided options.
Parameters
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'
).
Example
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);
estimateCrackTime(password, guessesPerSecond)
Estimates the time required to crack a password based on the number of guesses per second.
Parameters
password
(string): The password to estimate crack time for.guessesPerSecond
(number): The estimated number of guesses a computer can make per second.
Example
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.`);