@bhavana_lagadapati/password_utilities
v1.0.2
Published
password utilities provides various functions for password generation,validation and security
Maintainers
Readme
Here's the README.md formatted based on your provided code:
# Password Utilities Module
The *Password Utilities Module* is a lightweight and reusable library designed to simplify password management in JavaScript projects. It provides various functions for password generation, validation, and security, making it highly useful for applications, including MERN stack projects.
---
## Features
1. *Password Generation*: Create random passwords with customizable options for letters, numbers, and symbols.
2. *Strength Validation*: Check if a password meets specified strength criteria (e.g., length, uppercase, numbers, symbols).
3. *Password Hashing*: Securely hash passwords using the bcrypt library.
4. *Hash Verification*: Verify if a plain text password matches a hashed password.
5. *Common Password Check*: Check if a password is in a list of commonly used passwords for enhanced security.
---
## Installation
To use the *Password Utilities Module* in your project, install it via npm:
```bash
npm install @bhavana_lagadapati/password-utilitiesUsage
Importing the Module
ES Modules:
import PasswordUtils from '@bhavana_lagadapati/password-utilities';CommonJS:
const PasswordUtils = require('password-utilities');Available Functions
1. generate(length, options)
Generates a random password with customizable options for letters, numbers, and symbols.
Parameters:
length: The desired length of the password (default:12).options: An object with boolean properties (letters,numbers,symbols) to specify character types (default:{ letters: true, numbers: true, symbols: true }).
Example:
const password = PasswordUtils.generate(16, { letters: true, numbers: true, symbols: true });
console.log(password); // Output: Randomly generated password2. isStrong(password)
Checks if a password meets strength criteria:
- At least 8 characters long
- Includes uppercase letters, lowercase letters, numbers, and symbols
Parameters:
password: The password to validate.
Example:
console.log(PasswordUtils.isStrong("My$ecureP@ss123")); // Output: true3. hash(password)
Hashes a password securely using the bcrypt library.
Parameters:
password: The plain text password to hash.
Example:
const hashedPassword = PasswordUtils.hash("My$ecureP@ss123");
console.log(hashedPassword); // Output: A hashed password4. verifyHash(password, hash)
Verifies if a plain text password matches its hashed version.
Parameters:
password: The plain text password.hash: The hashed password to verify against.
Example:
const isValid = PasswordUtils.verifyHash("My$ecureP@ss123", hashedPassword);
console.log(isValid); // Output: true or false5. isCommonPassword(password)
Checks if a password is among a list of commonly used passwords for improved security.
Parameters:
password: The password to check.
Example:
console.log(PasswordUtils.isCommonPassword("password123")); // Output: trueUse Cases
1. User Registration
- Use Case: Generate secure default passwords for new users or validate the strength of user-created passwords.
- Example:
const isStrong = PasswordUtils.isStrong("My$ecureP@ss123"); if (!isStrong) console.log("Password must be stronger!");
2. Authentication Systems
- Use Case: Securely store and validate user passwords.
- Example:
const hashedPassword = PasswordUtils.hash("userPassword"); const isValid = PasswordUtils.verifyHash("userPassword", hashedPassword); console.log(isValid); // Output: true
3. Security Checks
- Use Case: Prevent users from using commonly used passwords during registration.
- Example:
if (PasswordUtils.isCommonPassword("123456")) { console.log("Choose a more secure password!"); }
4. Admin Tools
- Use Case: Generate strong passwords for admin accounts.
- Example:
const adminPassword = PasswordUtils.generate(20, { letters: true, numbers: true, symbols: true }); console.log("Admin Password:", adminPassword);
5. E-Commerce
- Use Case: Validate customer passwords during registration or login to meet strength criteria.
- Example:
const isStrong = PasswordUtils.isStrong("Shop@Secure123"); if (!isStrong) console.log("Password must include symbols and numbers!");
This `README.md` gives a detailed overview of the module, its features, installation, usage examples, and potential use cases. Let me know if you need any further modifications!