brendanashworth / generate-password

NodeJS library for generating cryptographically-secure passwords.
MIT License
354 stars 67 forks source link

[bug] Password generation with numbers #47

Closed carlosfanti closed 4 years ago

carlosfanti commented 4 years ago

Similar to the #46, when using the param numbers:true, the generation no always result on a password with number.

You can see the behavior on the code test bellow https://runkit.com/carlosfanti/generate-password-bug-numbers-true

image

carlosfanti commented 4 years ago

If I use strict:true, it works well:

image

dillonstreator commented 4 years ago

@carlosfanti This is not a bug. It's by design. Setting numbers:true does not guarantee you a number. It just means that numbers will be apart of a pool of characters that could be drawn from. It does not guarantee that you will get a number. This is the reason for the strict param. strict guarantees that your output contains one character from each set.

carlosfanti commented 4 years ago

@DillonStreator Thank you for the explanation!

francofantini commented 3 years ago

OMHO strict should default to true.