DEV Community

Discussion on: Public Solving: Generating secure password

Collapse
 
dailydevtips1 profile image
Chris Bongers

Nice one!
What's the bad thing about using Math.random?

Do like your super randomness function, smart to use the remained for that.
I think I hit a use-case when trying that where a option would not be added.

So thanks for this solution, great idea to make sure at least the options are set once and then re-shuffle for extra randomness.

Collapse
 
lexlohr profile image
Alex Lohr

Math.random is not random enough, it's just a seeded pseudo-random number generator. So if an attacker knows your code, they can reduce a lot of the possible combinations they would need to try. The same goes for cycling the options, just even worse so, because instead of 72 possible characters for each positions, there would now be only 26 or even 10 left.

Thread Thread
 
dailydevtips1 profile image
Chris Bongers

They should really rename that function 😂
Yeah I've taken in account it would not be the most "random" version because of the looping method always being the same.

Thanks Alex 👏