Giter Site home page Giter Site logo

junkurihara / generate-password Goto Github PK

View Code? Open in Web Editor NEW

This project forked from brendanashworth/generate-password

13.0 2.0 2.0 2.17 MB

Universal (Node.js and browsers) library for generating cryptographically-secure passwords.

License: MIT License

JavaScript 53.78% TypeScript 46.22%

generate-password's Introduction

Generate Password TS

npm version codecov Unit Test

This library generate-password-ts was forked from the original Node.js version generate-password: https://github.com/brendanashworth/generate-password. This forked version was totally re-written in TypeScript from the original JS version and supports not only Node.js but also browsers without need of crypto-browserify.

Generate Password is a (relatively) extensive library for generating random and unique passwords.

Install

$ npm install generate-password-ts --save

or

$ yarn add generate-password-ts

For browsers, you can use node_modules/generate-password-ts/dist/generate-password-ts.bundle.js via script tags. If you simply import it at your code and use webpack (v5+), crypto-browserify should be explicitly ignored by specifying

resolve: {
  fallback: { 'crypto': false }
}

in webpack.config.js.

Usage

generate([options])

Generate one password with the given options. Returns a string.

import generator from 'generate-password-ts';

const password = generator.generate({
	length: 10,
	numbers: true
});

// 'uEyMTw32v9'
console.log(password);

generateMultiple(amount[, options])

Bulk generate multiple passwords at once, with the same options for all. Returns an array.

import generator from 'generate-password-ts';

const passwords = generator.generateMultiple(3, {
	length: 10,
	uppercase: false
});

// [ 'hnwulsekqn', 'qlioullgew', 'kosxwabgjv' ]
console.log(passwords);

Available options

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

Name Description Default Value
length Integer, length of password. 10
numbers* Boolean, put numbers in password. false
symbols* Boolean or String, put symbols in password. false
lowercase* Boolean, put lowercase in password true
uppercase* Boolean, use uppercase letters in password. true
excludeSimilarCharacters Boolean, exclude similar chars, like 'i' and 'l'. false
exclude String, characters to be excluded from password. ''
strict Boolean, password must include at least one character from each pool. false

*At least one should be true.

generate-password's People

Contributors

renovate[bot] avatar renovate-bot avatar junkurihara avatar brendanashworth avatar kaworu avatar bartinthefield avatar rhyek avatar eddiecooro avatar donedgardo avatar jonasholtkamp avatar sketchthat avatar tanukisharp avatar starkteetje avatar dependabot[bot] avatar dillonstreator avatar sunjoong85 avatar

Stargazers

Marco Asta avatar Ano Rebel avatar Vince Fulco--Bighire.tools avatar Sergey Piskunov avatar h4nyu avatar Nripendra Nath Newa avatar Lukas Elmer avatar ('3') avatar Qi-Mo Lin avatar Shapkarin avatar  avatar Sergio Antonio Trujillo del Valle avatar Florian avatar

Watchers

James Cloos avatar  avatar

Forkers

antoni thomergil

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.