jonschlinkert / randomatic

Easily generate random strings like passwords, with simple options for specifying a length and for using patterns of numeric, alpha-numeric, alphabetical, special or custom characters. (the original "generate-password")
https://github.com/jonschlinkert
MIT License
183 stars 25 forks source link

not generating number #23

Closed markl-vesper closed 5 years ago

markl-vesper commented 5 years ago

Hi

Just started using this package. Looks nice

Used ('Aa0!', 10) as the options and the password returned was eVs)ho=pZ; which is failing to include a number.

Is the pattern simply what the generater 'could' include when generating the password and not 'must' include perhaps?

Wondering how it ended up generating a string without a number.......

Thanks

doowb commented 5 years ago

Is the pattern simply what the generater 'could' include when generating the password and not 'must' include perhaps?

Correct. Given the list of characters to choose from, random characters are chosen up to the provided length.

Wondering how it ended up generating a string without a number.......

Since randomatic randomly chooses characters from the list, there's not guarantee that characters from specific groups will be chosen. Also, it looks like you're using randomatic as a password generator, but that's not randomatic's only use case. This gives developers like you the ability to build specific implementations using randomatic for specific user cases.

I'm not sure exactly what the code looks like, but I can envision a function that calls randomatic multiple times given different character groups to ensure characters are included. This would be useful for a password generator since you can provide it with the rules for what must be in a password.

I'm going close this, but if you run into any bugs while using randomatic, please feel free to open a new issue. If you have an additional questions, feel free to continue the discussion on this issue.