Comments (4)
Thanks @ADIOP55550 for reporting this and @fshields for finding the solution to the bug. I was able to confirm it with a test case and pushed a fix to npm as 2.2.2
from password-generator.
There is a file containing result of 500 calls password-generator -c -l 50 -p "[a-zA-Z]"
. No 'A's!
result.txt
from password-generator.
I've run into this issue as well. In fact, It happens even with digits. For example:
generatePassword(12, false, /\d/)
will never generate a password with a zero in it (despite the README showing this as an example with a "0" in the output.)
I think I've discovered more about the issue. It seems that it is dropping the character with the lowest ASCII value from the list of character choices. So if you run this:
generatePassword(12, false, /AB5/)
you will get a password with only "A" and "B" characters, but never a "5" because the character "5" has a lower ASCII value than any of the other characters.
ASCII Values:
"5" - decimal 53, hex 35
"A" - decimal 65, hex 41
"B" - decimal 66, hex 42
from password-generator.
I'm pretty sure that the error lies in line 84 of /dist/password-generator.js:
if (value > min && value < max) {
The return from this function is used to select a character from a zero-based array. However, "value" can never be zero because "min" is zero; and 0 is not less than 0 (ever).
I think that line 84 should be changed to:
if (value >= min && value < max) {
so that the zero-ith element of the validChars[]
array can be chosen.
from password-generator.
Related Issues (20)
- Multiple pattern checks HOT 2
- A cryptographically secure PRNG (crypto.getRandomValues) should be used instead of Math.random HOT 2
- Old version in bower repo HOT 2
- memorable option should not disable pattern HOT 2
- Doesn't work in old versions of IE as claimed HOT 1
- algorithm behind HOT 1
- switch to minimist HOT 4
- [Request] Add support for angular HOT 3
- Request: Add support for random seed HOT 1
- Uniqueness HOT 2
- Unable to generate a password with the tilde character HOT 1
- Don't use `Math.random` in example on README
- vulnerable dependency: yargs-parser HOT 1
- v2.3.x Do Not Handle Commandline Arguments HOT 3
- Missing dist folder in npm install or yarn 2.x
- How to make sure password contains both letters and characters HOT 3
- Hangs HOT 1
- RangeError: Maximum call stack size exceeded HOT 1
- Please add bower support HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from password-generator.