Socket
Book a DemoInstallSign in
Socket

js-generate-password

Package Overview
Dependencies
Maintainers
3
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-generate-password

Password Generator for using in javascript/typescript based projects.

1.0.0
latest
Source
npmnpm
Version published
Weekly downloads
1.4K
-13.22%
Maintainers
3
Weekly downloads
 
Created
Source


npm Info

npm Version npm Release Version npm Downloads npm Package License

github Stars github Forks github Contributors github Issues


js-generate-password

js-generate-password is usable for every typescript and typescript based project like react, vue, node, etc. it used to generate passwords that may contain alphabets, number and symbols. The options parameter enables the user to enable or disable the characters that are used to generate random password.

The characters that may be choosen from are

  • Lowercase Characters
  • Uppercase Characters
  • Numbers
  • Symbols

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

Installation

npm install js-generate-password

or

yarn add js-generate-password

Usage

For the password to be generated, parameters are able to pass as an optional options object.

import { GeneratePassword } from "js-generate-password";

const password = GeneratePassword({
  length: 14,
  symbols: true,
});

console.log(password);

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

options = {
  length: 10,
  lowercase: true,
  uppercase: true,
  numbers: true,
  symbols: false,
  exclude: "",
  minLengthLowercase: 1,
  minLengthUppercase: 1,
  minLengthNumbers: 1,
  minLengthSymbols: 0,
};

Available options

Any of these can be passed into the options object for each function.

NameDescriptionDefault Value
lengthInteger, length of password.10
lowercase*Boolean, put lowercase letters in passwordtrue
uppercase*Boolean, put uppercase letters in password.true
numbers*Boolean, put numbers in password.true
symbols*Boolean, put symbols in password.false
excludeString, characters to be excluded from password.''
minLengthLowercaseonly if lowercase is set to true, minLengthLowercase will create a password that will have minimum number of lower case characters in the password.1
minLengthUppercaseonly if uppercase is set to true, minLengthUppercase will create a password that will have minimum number of upper case characters in the password.1
minLengthNumbersonly if numbers is set to true, minLengthNumbers will create a password that will have minimum number of numbers in the password.1
minLengthSymbolsonly if symbols is set to true, minLengthSymbols will create a password that will have minimum number of symbols in the password.1
  • At least one should be true.

Example

  • No Options passed.
const { GeneratePassword } = "js-generate-password";

const password = GeneratePassword();

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, numbers, and will be of length 10 characters.

xDU6izb3PV;
  • Length parameter passed.
const password = GeneratePassword({ length: 25 });
console.log(password);

The password generated is like this

U4c3KpQP5UrbZgTcrqMgFeI3R;
  • exclude parameter passed.
options = {
  exclude : 'abc567XYZ';
}

password = GeneratePassword(options);

console.log(password);

The generated password wouldn't has none of 'abc567XYZ' characters

J9yCfttQNj;

License

js-generate-password is licensed under the MIT License. See the LICENSE file for more details.

Keywords

generate password

FAQs

Package last updated on 04 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.