Understanding the random password generator — concept and principle
This tool creates a random password on your own device using the browser's cryptographically secure random number generator, and reports its entropy in bits. Unlike a password you invent, a generated one has a strength that can be calculated exactly, which makes it ideal for accounts stored in a password manager, Wi-Fi keys and API secrets.
How it is calculated
- Character set: 24 uppercase letters (no I or O), 25 lowercase letters (no l) and the digits 2–9, which is 57 characters chosen to avoid look-alikes such as 0/O and 1/l/I. With symbols on, 13 more are added (! @ # $ % ^ & * - _ = + ?), for 70 in total.
- Generation: for each character, a 32-bit random number is drawn with crypto.getRandomValues. Numbers at or above the largest multiple of the set size below 2^32 are discarded and redrawn (rejection sampling); the rest are reduced modulo the set size to pick a character. If the password lacks an uppercase letter, a lowercase letter, a digit or (when chosen) a symbol, it is redrawn. Length is capped at 256.
- Entropy (bits) = log₂ of the number of passwords that contain every required class, counted by inclusion–exclusion; slightly less than length × log₂(set size).
The principle
Entropy counts how many equally likely passwords the generator could have produced. With 70 symbols and 20 positions there are 70^20 possibilities. That is only true if every character is equally likely: taking a raw random number modulo 70 would slightly favour some characters, because 2^32 is not a multiple of 70. Rejection sampling removes that bias, so each character carries the full log₂ 70 ≈ 6.13 bits.
Worked example
- Inputs: length 20, symbols included.
- Set size: 57 + 13 = 70; bits per character = log₂ 70 = 6.129283.
- 20 × 6.129283 = 122.5856603 bits counts every string, but about 10.4% miss a class and are never produced, so entropy = 122.4267914 bits.
- A sample output is w%?tKmFrSfMhitxK4R?_. Your password will be different every time; that is the point.
- Without symbols the set has 57 characters and the same length gives about 116.6 bits.
How to read the result
Above about 80 bits a random password is out of reach of offline brute force even against fast hashes; 128 bits matches the strength of modern encryption keys. If a site rejects symbols, switch them off and add a character or two.
Common mistakes
- Editing a generated password to make it memorable, which lowers its real entropy.
- Worrying that the every-class rule weakens the password; here it costs only about 0.16 bits.
Frequently asked questions
What length should a random password be?
For accounts kept in a password manager, 16 to 20 characters from this set gives roughly 95 to 120 bits, more than enough for most uses.
Is the password sent or stored anywhere?
No. It is generated locally and disappears when you leave the page.
Sources: W3C Web Cryptography API, Crypto.getRandomValues() · NIST SP 800-90A Rev. 1, Recommendation for Random Number Generation Using Deterministic Random Bit Generators