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

random-passwords-generator

v1.0.5

Published

A npm package that helps you generate random passwords by passing in a criteria.

Downloads

3

Readme

random-passwords-generator

Build Status

Random passwords generator is used to generate passwords that may contain alphabets, number and special characters. The options parameter enables the user to enable or disabe the characters that are used to generate the password. The characters that may be choosen from are

  • Lowercase Characters
  • Uppercase Characters
  • Numbers
  • Special characters

The user may also opt to choose the first character in the password. The first character may one of the below.

  • Lowercase Character
  • Uppercase Character
  • Number
  • Special Character

The user may also specify the minimum number of character of each type.

Installation

npm install random-passwords-generator

Usage

For the password to be generated, PARAMETERS should be passed as an optional options object.

If no parameter is passed, the default parameter will be taken as :

options = {
      LENGTH: 10,
      ALLOW_ALPHABETS_LOWERCASE: true,
      ALLOW_ALPHABETS_UPPERCASE: true,
      ALLOW_NUMBERS: true,
      ALLOW_SPECIAL_CHARACTERS: true,
      EXCEPTIONS: "",
      FIRST_CHARACTER_LOWERCASE: true,
      FIRST_CHARACTER_UPPERCASE: false,
      FIRST_CHARACTER_NUMBER: false,
      FIRST_CHARACTER_SPECIAL_CHARACTER: false,
      MIN_ALPHABETS_LOWERCASE: 1,
      MIN_ALPHABETS_UPPERCASE: 1,
      MIN_NUMBERS: 1,
      MIN_SPECIAL_CHARACTERS: 1,
    };

The parameters are

  1. LENGTH : the length of the password to be generated. Default Value : 10.

  2. ALLOW_ALPHABETS_LOWERCASE : can take a boolean value that decides whether the password can have lowecase alphabets. Default Value : true.

  3. ALLOW_ALPHABETS_UPPERCASE : can take a boolean value of true or false. If true, the password generated can have uppercase characters. Default Value : false.

  4. ALLOW_NUMBERS: : option can take a boolean which decides wherher the password generated can have numbers.

  5. ALLOW_SPECIAL_CHARACTERS : option accepts boolean value and decides whether the password generated can have special characters. The special characters are : !#$%&'()+,-./:;<=>?@[]^_`{|}~*

  6. EXCEPTIONS : exception takes in a string of characters that would not be used to generate the password. If "abc" is passed as exceptions, then the password willnot have the characters a,b,c

  7. FIRST_CHARACTER_LOWERCASE - only if ALLOW_ALPHABETS_LOWERCASE is set to true, FIRST_CHARACTER_LOWERCASE will create a password that will have the first character as a lowercase character. Default value is true.

  8. FIRST_CHARACTER_UPPERCASE - only if ALLOW_ALPHABETS_UPPERCASE is set to true, FIRST_CHARACTER_UPPERCASE will create a password that will have the first character as uppercase. Default value is false.

  9. FIRST_CHARACTER_NUMBER - only if ALLOW_NUMBERS is set to true, FIRST_CHARACTER_NUMBER will create a password that will have the first character as number. Default value is false.

  10. FIRST_CHARACTER_SPECIAL_CHARACTER - only if ALLOW_SPECIAL_CHARACTERS is set to true, FIRST_CHARACTER_SPECIAL_CHARACTER will create a password that will have the first character as special character. Default value is false.

  11. MIN_ALPHABETS_LOWERCASE - only if ALLOW_ALPHABETS_LOWERCASE is set to true, MIN_ALPHABETS_LOWERCASE will create a password that will have minimum number of lower case characters in the password. Default value is 1.

  12. MIN_ALPHABETS_UPPERCASE - only if ALLOW_ALPHABETS_UPPERCASE is set to true, MIN_ALPHABETS_UPPERCASE will create a password that will have minimum number of upper case characters in the password. Default value is 1.

  13. MIN_NUMBERS - only if ALLOW_NUMBERS is set to true, MIN_NUMBERS will create a password that will have minimum number of numbers in the password. Default value is 1.

  14. MIN_SPECIAL_CHARACTERS - only if ALLOW_SPECIAL_CHARACTERS is set to true, MIN_SPECIAL_CHARACTERS will create a password that will have minimum number of special characters in the password. Default value is 1.

Example

  • No Options passed.
const passwords = require("random-passwords-generator");
password = passwords();
console.log(password);

In the above case, no parameter is passed as option. Therefore the default values will be taken - which will have alphabets, both upper and lower case, special characters and will be of length 10 characters.

j8GGa3Udr8
  • Length parameter passed.
options={
      LENGTH : 25;
      }
password = passwords(options);
console.log(password);

The password generated is

t4eWL36LxL=h-cnqirU,T841l
  • Only Characters(Lower and Upper) Password - Without Numbers and Special Characters
options = {
      LENGTH: 25,
      ALLOW_ALPHABETS_LOWERCASE: true,
      ALLOW_ALPHABETS_UPPERCASE: true,
      ALLOW_NUMBERS: false,
      ALLOW_SPECIAL_CHARACTERS: false,
      EXCEPTIONS: "",
      FIRST_CHARACTER_LOWERCASE: true,
      FIRST_CHARACTER_UPPERCASE: false,
      FIRST_CHARACTER_NUMBER: false,
      FIRST_CHARACTER_SPECIAL_CHARACTER: false,
      MIN_ALPHABETS_LOWERCASE: 1,
      MIN_ALPHABETS_UPPERCASE: 1,
      MIN_NUMBERS: 1,
      MIN_SPECIAL_CHARACTERS: 1,
    };

passwords = password(options);
console.log(passwords);

In the above case, the password generated will have alphabets, both lower and uppercase and will not have numbers and special characters.

    gjjmvsxiqVTiPRwbzcHVGGHTM
  • Only Numbers(Lower and Upper) Password - Without Alphabets (Lower and Upper) and Special Characters
options = {
      LENGTH: 25,
      ALLOW_ALPHABETS_LOWERCASE: false,
      ALLOW_ALPHABETS_UPPERCASE: false,
      ALLOW_NUMBERS: true,
      ALLOW_SPECIAL_CHARACTERS: false,
      EXCEPTIONS: "",
      FIRST_CHARACTER_LOWERCASE: true,
      FIRST_CHARACTER_UPPERCASE: false,
      FIRST_CHARACTER_NUMBER: false,
      FIRST_CHARACTER_SPECIAL_CHARACTER: false,
      MIN_ALPHABETS_LOWERCASE: 1,
      MIN_ALPHABETS_UPPERCASE: 1,
      MIN_NUMBERS: 1,
      MIN_SPECIAL_CHARACTERS: 1
    };

passwords = password(options);
console.log(passwords);

The password will contain numbers only without any characters or special characters.

    3823264088081960859802441
  • Only Special Characters Password - Without Alphabets (Lower and Upper) and Numbers
options = {
      LENGTH: 25,
      ALLOW_ALPHABETS_LOWERCASE: false,
      ALLOW_ALPHABETS_UPPERCASE: false,
      ALLOW_NUMBERS: false,
      ALLOW_SPECIAL_CHARACTERS: true,
      EXCEPTIONS: "",
      FIRST_CHARACTER_LOWERCASE: true,
      FIRST_CHARACTER_UPPERCASE: false,
      FIRST_CHARACTER_NUMBER: false,
      FIRST_CHARACTER_SPECIAL_CHARACTER: false,
      MIN_ALPHABETS_LOWERCASE: 1,
      MIN_ALPHABETS_UPPERCASE: 1,
      MIN_NUMBERS: 1,
      MIN_SPECIAL_CHARACTERS: 1
    };

passwords = password(options);
console.log(passwords);

The password will contain numbers only without any characters or special characters.

    *,._>_.-<)-(&|>_#.,&(*|#;
  • Minimum number of characters. Password of length 10 - 9 characters lowercase and 1 character uppercase
options = {
      LENGTH: 10,
      ALLOW_ALPHABETS_LOWERCASE: true,
      ALLOW_ALPHABETS_UPPERCASE: true,
      ALLOW_NUMBERS: false,
      ALLOW_SPECIAL_CHARACTERS: false,
      EXCEPTIONS: "",
      FIRST_CHARACTER_LOWERCASE: true,
      FIRST_CHARACTER_UPPERCASE: false,
      FIRST_CHARACTER_NUMBER: false,
      FIRST_CHARACTER_SPECIAL_CHARACTER: false,
      MIN_ALPHABETS_LOWERCASE: 9,
      MIN_ALPHABETS_UPPERCASE: 1,
      MIN_NUMBERS: 1,
      MIN_SPECIAL_CHARACTERS: 1
    };

passwords = password(options);
console.log(passwords);

The password will contain numbers only without any characters or special characters.

    pXhusaahuq

The options can be altered as per the requirement to generate the required password of required strength and complexity.

NOTE : If values are not assigned to the options, then the default values will be taken.

License

Copyright (c) 2020 Nixon Augustine

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.