Gathering detailed insights and metrics for password-generator
Gathering detailed insights and metrics for password-generator
Gathering detailed insights and metrics for password-generator
Gathering detailed insights and metrics for password-generator
npm install password-generator
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
448 Stars
84 Commits
58 Forks
16 Watching
8 Branches
6 Contributors
Updated on 08 Oct 2024
Minified
Minified + Gzipped
JavaScript (92.15%)
Makefile (7.85%)
Cumulative downloads
Total Downloads
Last day
44.6%
6,618
Compared to previous day
Last week
94.9%
45,723
Compared to previous week
Last month
28.8%
131,183
Compared to previous month
Last year
-19.1%
1,519,376
Compared to previous year
Memorable password generator. For the command line, Node.js and browsers.
$ npm install password-generator -g
password-generator -h
Displays this help
Generates a memorable password
Options:
-l Password length
-c Generates a non memorable password [default: false]
-p Pattern to match for the generated password
-h Displays this help
Simple memorable pass
password-generator
=> maqetaxaku
Custom length
password-generator -l 30
=> nugiferagiraqadamedewubaqirali
Non memorable
password-generator -c
=> QPnb3gl7_0
Customize the pattern to match for each password character
password-generator -p "[\d\W\w\p]"
=> Je;VgG?{Yd
Any number or letter
password-generator -p "[\w]"
=> 3NHPqzjIAq
Combine multiple strategies 6 memorable and 3 numbers
echo "`password-generator -l 6``password-generator -p "[0-9]" -l 3`"
=> wazawe351
var generatePassword = require('password-generator');
<script src="https://raw.github.com/bermi/password-generator/master/dist/password-generator.min.js" type="text/javascript"></script>
Since v2.0.0 this library relies on cryptographic random values generated via crypto.getRandomValues
. IE11 was the first IE version to include this method. Check caniuse.com for details.
generatePassword() // -> xexeyimahi
generatePassword(12, false) // -> 76PAGEaq6i5c
generatePassword(12, false, /\d/) // -> 252667390298
generatePassword(12, false, /\d/, 'foo-') // -> foo-67390298
Given the pattern regexp can only match a single character you can build a function that generates multiple passwords until you hit one that complies with your rules.
The following example will generate a password with the following requirements
1var generatePassword = require("password-generator"); 2 3var maxLength = 18; 4var minLength = 12; 5var uppercaseMinCount = 3; 6var lowercaseMinCount = 3; 7var numberMinCount = 2; 8var specialMinCount = 2; 9var UPPERCASE_RE = /([A-Z])/g; 10var LOWERCASE_RE = /([a-z])/g; 11var NUMBER_RE = /([\d])/g; 12var SPECIAL_CHAR_RE = /([\?\-])/g; 13var NON_REPEATING_CHAR_RE = /([\W\w\d\?\-])\1{2,}/g; 14 15function isStrongEnough(password) { 16 var uc = password.match(UPPERCASE_RE); 17 var lc = password.match(LOWERCASE_RE); 18 var n = password.match(NUMBER_RE); 19 var sc = password.match(SPECIAL_CHAR_RE); 20 var nr = password.match(NON_REPEATING_CHAR_RE); 21 return password.length >= minLength && 22 !nr && 23 uc && uc.length >= uppercaseMinCount && 24 lc && lc.length >= lowercaseMinCount && 25 n && n.length >= numberMinCount && 26 sc && sc.length >= specialMinCount; 27} 28 29function customPassword() { 30 var password = ""; 31 var randomLength = Math.floor(Math.random() * (maxLength - minLength)) + minLength; 32 while (!isStrongEnough(password)) { 33 password = generatePassword(randomLength, false, /[\w\d\?\-]/); 34 } 35 return password; 36} 37 38console.log(customPassword()); // => 2hP5v?1KJNx7_a-W
npm install
make test
npm install
make all
(The MIT License)
Copyright (c) 2011-2020 Bermi Ferrer <bermi@bermilabs.com>
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.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 3/26 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
12 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More