1.0.2 • Published 1 year ago
r-password v1.0.2
r-password
A simple and flexible random password generator. This package allows you to generate secure passwords with customizable options.
Table of Contents
Installation
To install the package, use npm:
npm install r-passwordUsage
You can use the generateRandomPassword function to create a random password. Import the function in your JavaScript file:
const generateRandomPassword = require("r-password");Options
The generateRandomPassword function takes the following parameters:
| Parameter | Type | Description | 
|---|---|---|
length | number | The length of the password to be generated. | 
includeNumbers | boolean | Whether to include numbers (default: true). | 
includeUppercase | boolean | Whether to include uppercase letters (default: true). | 
includeLowercase | boolean | Whether to include lowercase letters (default: true). | 
includeSymbols | boolean | Whether to include symbols (default: false). | 
Examples
Basic Usage
const generateRandomPassword = require("r-password");
// Generate a password of length 12 with numbers, uppercase letters, lowercase letters, and symbols
const password = generateRandomPassword(12, true, true, true, true);
console.log("Generated Password:", password);Custom Options
// Generate a password of length 16 with only lowercase letters and numbers
const password2 = generateRandomPassword(16, true, false, true, false);
console.log("Generated Password:", password2);Error Handling
If no character types are selected, an error will be thrown:
try {
  const password3 = generateRandomPassword(10, false, false, false, false);
} catch (error) {
  console.error("Error:", error.message); // "At least one character type must be selected"
}License
This project is licensed under the MIT License. See the LICENSE file for more details.