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

use cryptographically secure random function #11

Closed michaelrhodes closed 6 years ago

michaelrhodes commented 6 years ago

Closes #4

michaelrhodes commented 6 years ago

It might also be worth exporting require('math-random').cryptographic so that older browsers can easily check which type of random function is being used

doowb commented 6 years ago

I think this looks great. I think adding the .cryptographic property is a good idea to give browser app implementors the choice on if they want to support older browsers.

michaelrhodes commented 6 years ago

Agreed. I’ll update the pull request? And if so, what’s your preferred property name? Is cryptographic fine, or should I go for something more descriptive like isCryptographicallySecure or isSecure?

doowb commented 6 years ago

I think .isCrypto is good.

Also, add some documentation to .verb.md that explains what it means. I think it's fine to say something like, "isCrypto will be true when a cryptographic library is being used, otherwise, Math.random is being used."

jonschlinkert commented 6 years ago

I think .isCrypto is good.

Agreed, I think isCrypto makes sense since it's a boolean confirming that the built-in crypto lib was used.

Nice work, thanks!

michaelrhodes commented 6 years ago

Okie dokie gang, I believe this is good to go now :)

Edit: That said, I was a bit unsure where to fit the documentation into .verb.md, so I just did what made sense to me. Let me know if you think it should be under its own heading.

jonschlinkert commented 6 years ago

thanks! published and released as 3.0.0!

tomByrer commented 6 years ago

Cheers @michaelrhodes & @jonschlinkert