How to Generate a Secure Password
Verizon's 2025 Data Breach Investigations Report found compromised credentials were the initial way in for 22% of the 12,195 breaches it analyzed — the most common single vector — and reused or predictable passwords are what make stolen and guessed credentials work. A randomly generated password with sufficient length and character variety is exponentially harder to crack than anything a human would choose. Understanding why — and how to generate them properly — is fundamental to personal and application security.
Why Random Passwords Matter
Human-chosen passwords follow predictable patterns: dictionary words, personal information (birthdays, pet names), keyboard walks (qwerty, 123456), and common substitutions (p@ssw0rd). Attackers know these patterns and build dictionaries specifically targeting them. A randomly generated password has no pattern to exploit — the only attack is brute force, which becomes impractical with sufficient length and character variety.
Understanding Password Entropy
Entropy measures the unpredictability of a password in bits. A password with N bits of entropy has 2^N possible combinations. The formula is: entropy = length × log2(character pool size). A 12-character password using uppercase, lowercase, digits, and symbols (95 characters) has about 79 bits of entropy — meaning 2^79 (roughly 604 sextillion) possible combinations. At 100 billion guesses per second, cracking it would take over 190,000 years. The Password Generator shows the entropy of each generated password.
Length vs Complexity
Length contributes more to entropy than character variety. A 20-character password using only lowercase letters (about 94 bits) is stronger than a 10-character password using all 95 printable characters (about 66 bits). NIST's current Digital Identity Guidelines (SP 800-63B-4, 2025) reflect this: services must require at least 15 characters for passwords used on their own (8 when used with another factor), should allow at least 64, and must not impose composition rules such as "one symbol and one digit" or force periodic changes.
Worked Example: The Bias Hiding in a Common Snippet
Entropy figures assume every character is equally likely. A snippet copied all over the web breaks that: it takes random bytes from crypto.getRandomValues() and picks a character with byte % pool.length. With 95 characters, 256 = 2 × 95 + 66, so the first 66 characters of the pool come up three times in every 256 bytes and the other 29 only twice. We drew 9.5 million characters each way in Node.js (script in our test folder, October 13, 2026):
byte % 95 | Rejection sampling | |
|---|---|---|
| Most / least frequent character | 1.53× | 1.01× |
| Share taken by the first 66 characters (fair: 69.5%) | 77.4% | 69.5% |
Rejection sampling simply throws away bytes of 190 or more (the largest multiple of 95 below 256) and draws again. The loss in entropy from the biased version is modest for one password, but it is free to avoid; our generator uses rejection sampling, and Math.random() should never be used for passwords at all, because it is not a cryptographically secure generator.
Passphrases: The Best of Both Worlds
A passphrase is a sequence of random words — like 'correct horse battery staple.' A 4-word passphrase drawn from a 7,776-word dictionary (the EFF wordlist) has about 51 bits of entropy. A 6-word passphrase has 77 bits — comparable to a complex 12-character password but far easier to type and remember. The key is that the words must be randomly selected, not chosen by a human. Our Password Generator creates random character passwords; for passphrases, roll dice against the EFF list or use a password manager's passphrase option.
Frequently Asked Questions
How long should a secure password be?
What is password entropy?
Is a passphrase more secure than a password?
- [1]Verizon Business: 2025 DBIR research on credential abuse (22% of breaches) ↗
- [2]NIST SP 800-63B-4 (2025): Digital Identity Guidelines — Authentication (password length, no composition rules) ↗
- [3]EFF: Dice-generated passphrases and the 7,776-word long list ↗
- [4]MDN Web Docs: Crypto.getRandomValues() ↗
- [5]MDN Web Docs: Math.random() (not cryptographically secure) ↗