npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

easy_random_password

v1.3.3

Published

This JavaScript function generates random passwords

Downloads

33

Readme

Generate Password

This JavaScript function generates passwords of various formats based on the specified options. You can customize the length and character sets included in the password.

install

$ npm i easy_random_password --save

Usage

Function Signature

function generatePassword(length, option)

Parameters

  • length (number): The length of the password to be generated.

  • option (object): An object specifying the character sets to include in the password.

Options Object

The options object can have the following boolean properties:

  • 'includeNumbers' (boolean): Whether to include numeric characters (e.g,'0-9')

  • 'includeAlphabet' (boolean): Whether to include alphabetic characters (e.g,'a-z, A-Z')

  • 'includeSpecial' (boolean): Whether to include special characters (e.g, '!@#$%^&*()')

  • 'includeupperCase' (boolean): Whether to include upperCase characters (e.g, 'A-Z')

  • 'includelowerCase' (boolean): Whether to include lowerCase characters (e.g, 'a-z')

Returns

'password' (string): The generated password.

Example Usage

Import or include the function in your script

CommonJS (Node.js)

  const generatePassword = require('easy_random_password');

ES Module (ES6+)

  import { generatePassword } from 'easy_random_password';

Example 1: This example Generate a random password by just specifying the length of the character to be included.

  const password = generatePassword(10);
  console.log(password);
  // 'H8?2IihD5*'
Note: If the option parameter is not included, it generates a password using a default value of true for all options

Example 2: Generate a 10-character password with numbers, alphabet, special, upperCase and lowerCase characters

  const option = {
    includeNumbers: true,
    includeAlphabet: true,
    includeSpecial: true,
    includelowerCase: true,
    includeupperCase: true,
  };
  const password = generatePassword(10, option);
  console.log(password);
  // 'H8?2IihD5*'

Example 3: Generate an 8-character password with numbers

const option = {
  includeNumbers: true,
};
const password = generatePassword(8, option);
console.log(password);
// '49076379'

Example 4: Generate an 8-character password with Alphabets only

 const option = {
   includeAlphabet: true,
 };
 const password = generatePassword(8, option);
 console.log(password);
// 'lNxUYohD'

Example 5: Generate an 8-character password with special characters only

 const option = {
   includeSpecial: true,
 };
 const password = generatePassword(8, option);
 console.log(password);
// ')%};|]@$'

Example 6: Generate an 8-character password with lowerCase only

 const option = {
   includelowerCase: true,
 };
 const password = generatePassword(8, option);
 console.log(password);
// 'nyknlzps'

Example 7: Generate an 8-character password with upperCase only

 const option = {
   includeupperCase: true,
 };
 const password = generatePassword(8, option);
 console.log(password);
// 'NQVJSAAB'

License

This project is licensed under the ISC License.

This README file provides an overview of the generatePassword function, detailing its usage, parameters, options, and example usages.

Contact

If you have any questions or feedback, please feel free to contact me at [email protected] or send a dm on linkedIn: http://linkedin.com/in/wisdom-michaels-320a99321.

Github

This link bellow will redirect you to my Github page if you want to read more about this package.

https://github.com/wisdommichaels/Password_generator