Is using Math.random in an online password generator dangerous? Entropy and Web Crypto
Why a password generator should use crypto.getRandomValues, how entropy is estimated, and how the TwoThink password generator works — including the option to exclude look-alike characters.
Many "online password generator" pages look fancy but are built on Math.random(). That may be just about good enough for an ordinary website login; for an important account, I would not gamble on it.
Which randomness source to use
The browser provides Web Crypto's crypto.getRandomValues, fed by the system entropy pool, which makes it suitable for key material. The TwoThink password generator uses only that, and samples uniformly so there is no "modulo bias".
What the strength bar is telling you
Strength is estimated with approximate entropy: length × log2(charset size).
- 6 digits only: very low entropy → weak
- 16 characters with mixed case, digits and symbols: normally in the "very strong" range
You can also turn on "exclude look-alikes" to drop 0 O I l 1 |, which makes hand-typing easier at the cost of a slightly smaller charset — and therefore slightly lower entropy.
Does the site keep a copy?
No. Generation and copying both happen in your browser, so the server never receives the password. Still, avoid leaving it on screen for long in public.
How it splits up with UUID and hash
- For a memorable login credential: use the password generator
- For a meaningless unique ID: use the UUID generator
- To verify file integrity: use the hash calculator