Secure Password Generator

Passwords are generated with crypto.getRandomValues(), which draws on your operating system’s cryptographic random source. Rejection sampling keeps every character equally likely, so the pool is not skewed towards whichever letters happen to fall early in it. Math.random() is not used anywhere in this site’s code.

Include
Weak 0 bits of entropy

How long is long enough

Every character you add multiplies the number of possible passwords. Entropy, measured in bits, is just a compact way of writing that number: each extra bit doubles the work an attacker has to do.

LengthLower-case onlyUpper, lower, digitsAll four sets
838 bits48 bits52 bits
1256 bits71 bits78 bits
1675 bits95 bits104 bits
24113 bits143 bits157 bits
32150 bits190 bits209 bits

Read across a row rather than down a column and the point becomes obvious: going from 8 characters to 16 buys far more than adding symbols to the 8. Length is the cheapest strength there is.

Around 80 bits is past the reach of any realistic offline attack. Everything above that is margin, which costs nothing if a password manager is doing the typing.

Where the randomness comes from

Passwords here are drawn from crypto.getRandomValues(), the browser's interface to the operating system's cryptographic random source (the same one that seeds TLS). Math.random() is not used anywhere in this site's code; it is fast and predictable, and predictable is fatal here.

Getting a random number from a random value takes one more step than it looks. The obvious approach (take a random 32-bit number and use the remainder after dividing by the pool size) is subtly biased, because 2³² does not divide evenly by 89. Some characters come up slightly more often than others, forever.

This generator uses rejection sampling instead: draw a value, and if it falls in the uneven tail, throw it away and draw again. Every character then has exactly the same chance, which is what the entropy figures above assume.

What a strong password does not protect you from

  • Reuse. A 32-character password used on two sites is as strong as the weaker site's database.
  • Phishing. Length is no help if you type it into the wrong place. A password manager that refuses to autofill on the wrong domain is.
  • A breach at the other end. Which is what two-factor authentication is for.

The password is one control among several. It is the one this tool can help with; it is not the one that fails most often.

Frequently asked questions

Is the generated password sent anywhere?

No. It is created in your browser and is never transmitted or stored, in a cookie or anywhere else. Close the tab and it is gone.

How long should my password be?

Length buys more strength than variety does. Sixteen characters with all four sets is around 104 bits, which is well past anything an attacker can brute-force. If you use a password manager, going longer costs you nothing.

Do I need symbols for a strong password?

Not necessarily. A longer password without symbols can beat a short one with them. If a system rejects symbols, turn them off and add length instead of shortening the password.

Why are quotes and backslashes excluded from the symbols?

Shell quoting, CSV export and form validators all tend to mangle them. A password you cannot paste into your own tools causes more trouble than the extra character is worth.