1.0.2 • Published 9 months ago

r-password v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

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-password

Usage

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:

ParameterTypeDescription
lengthnumberThe length of the password to be generated.
includeNumbersbooleanWhether to include numbers (default: true).
includeUppercasebooleanWhether to include uppercase letters (default: true).
includeLowercasebooleanWhether to include lowercase letters (default: true).
includeSymbolsbooleanWhether 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.

1.0.2

9 months ago

1.0.1

10 months ago

1.0.0

10 months ago