XKCD Generator
Generate XKCD-style passphrases with random word combinations.
How XKCD-style passwords work
Inspired by the XKCD comic, these passphrases combine random words to create passwords that are both secure and memorable. Four random words from a large dictionary provide approximately 44 bits of entropy.
Introduction
In 2011, Randall Munroe drew a comic that changed how the world thinks about password security. The XKCD #936 strip showed that 'correct horse battery staple' — four random English words — is both easier to remember and harder to crack than 'Tr0ub4dor&3', a typical 'strong' password. The XKCD Generator implements this exact principle: it selects random words from a large dictionary and concatenates them into passphrases that are memorable, typeable, and mathematically superior to random character strings. Four words give you 51.7 bits of entropy. Five words give you 64.6. Six words give you 77.5. Each additional word multiplies the attacker's work by 7,776 — and you just have to remember a silly sentence.
What This Tool Does
Why It Matters
The XKCD method exposed a fundamental flaw in traditional password advice: complexity (special characters, mixed case, numbers) provides linear gains in entropy, while length (more words) provides exponential gains. A 4-word passphrase from a 7,776-word dictionary has more entropy than a 10-character password using all 95 printable ASCII characters — and it's dramatically easier to remember. This insight has been validated by NIST, which now recommends passphrase-based approaches for high-value credentials. The XKCD Generator makes this insight practical by providing a simple, fast way to generate word-based passphrases with provable entropy.
How It Works
Step-by-Step Examples
Select 4 random words from the 7,776-word EFF Diceware list using crypto.getRandomValues()
Concatenate the words with spaces for natural readability
Each word contributes log₂(7776) ≈ 12.92 bits of entropy
Total entropy: 4 × 12.92 ≈ 51.7 bits with 3.7 × 10¹⁵ possible combinations
correct horse battery staple — 51.7 bits, the original XKCD example, memorable through absurd imagerySelect 6 random words from the EFF list
Concatenate with spaces
Total entropy: 6 × 12.92 ≈ 77.5 bits with 2.2 × 10²³ combinations
This exceeds the security of most random-character passwords
nebula whiskers accordion pineapple quantum ferret — 77.5 bits, computationally infeasible to crackCode Examples
// EFF Diceware wordlist: 7,776 common English words
import { EFF_WORDLIST } from './diceware-wordlist.js';
function generateXKCDPassphrase(wordCount = 4, separator = ' ') {
const words = [];
const randomValues = new Uint32Array(wordCount);
crypto.getRandomValues(randomValues);
for (let i = 0; i < wordCount; i++) {
// Map random 32-bit integer to wordlist index [0, 7776)
const index = randomValues[i] % EFF_WORDLIST.length;
words.push(EFF_WORDLIST[index]);
}
const entropy = wordCount * Math.log2(EFF_WORDLIST.length);
const combinations = Math.pow(EFF_WORDLIST.length, wordCount);
return {
passphrase: words.join(separator),
wordCount,
entropyBits: entropy.toFixed(1),
combinations: combinations.toExponential(2),
crackTime: estimateCrackTime(combinations)
};
}
function estimateCrackTime(combinations) {
const hashesPerSecond = 1e12; // GPU cluster
const seconds = combinations / 2 / hashesPerSecond;
if (seconds < 1) return 'Instant';
if (seconds < 31536000) return (seconds / 86400).toFixed(0) + ' days';
return (seconds / 31536000).toExponential(1) + ' years';
}
// Usage
const result = generateXKCDPassphrase(4);
console.log(result.passphrase); // e.g., "correct horse battery staple"
console.log(result.entropyBits); // "51.7"
console.log(result.crackTime); // "58.6 years"
// For high security:
const strong = generateXKCDPassphrase(6);
console.log(strong.entropyBits); // "77.5"function generateXKCDWithConfig(config = {}) {
const {
words = 4,
separator = ' ',
capitalize = false,
appendNumber = false
} = config;
// Generate random words
const randomValues = new Uint32Array(words);
crypto.getRandomValues(randomValues);
let wordArray = Array.from(randomValues)
.map(r => EFF_WORDLIST[r % EFF_WORDLIST.length]);
// Optional: capitalize first letter of each word
if (capitalize) {
wordArray = wordArray.map(w =>
w.charAt(0).toUpperCase() + w.slice(1)
);
}
// Optional: append a random number
let passphrase = wordArray.join(separator);
if (appendNumber) {
const numArray = new Uint32Array(1);
crypto.getRandomValues(numArray);
passphrase += separator + (numArray[0] % 100);
}
// Calculate entropy
let entropy = words * Math.log2(EFF_WORDLIST.length);
if (appendNumber) entropy += Math.log2(100);
return {
passphrase,
entropyBits: entropy.toFixed(1)
};
}
// Different configurations
console.log(generateXKCDWithConfig({ words: 4 }));
// "correct horse battery staple" — 51.7 bits
console.log(generateXKCDWithConfig({ words: 5, capitalize: true, appendNumber: true }));
// "Correct Horse Battery Staple 42" — 71.3 bitsXKCD Passphrase Entropy Scaling
| Words | Entropy (bits) | Combinations | Brute-Force Time (1T h/s) | Comparison |
|---|---|---|---|---|
| 2 | 25.8 | 6.0 × 10⁷ | 0.001 seconds | Worse than a 4-digit PIN |
| 3 | 38.8 | 4.7 × 10¹¹ | 0.0075 seconds | Crackable in real-time |
| 4 | 51.7 | 3.7 × 10¹⁵ | 58.6 years | Better than most passwords |
| 5 | 64.6 | 2.8 × 10¹⁹ | 902,000 years | Strong for general use |
| 6 | 77.5 | 2.2 × 10²³ | 7.0 × 10⁹ years | Very strong |
| 7 | 90.4 | 1.7 × 10²⁷ | 5.4 × 10¹³ years | Master password grade |
XKCD Method vs Traditional Password Complexity
| Method | Example | Entropy | Memorability | Typing Ease |
|---|---|---|---|---|
| XKCD (4 words) | correct horse battery staple | 51.7 bits | High — verbal memory | High — natural words |
| XKCD (6 words) | nebula whiskers accordion pineapple quantum ferret | 77.5 bits | High — absurd imagery | High — natural words |
| Traditional (12 char) | k9$mPx2#nLq! | 78.8 bits | Low — abstract characters | Low — requires shift keys |
| Traditional (16 char) | aK9$mPx2#nLq!vR7@ | 105.1 bits | Very Low — impossible to remember | Very Low — complex typing |
| Passphrase (5 words) | plumber rocket jungle mosaic faucet | 64.6 bits | High — visual memory | High |
Benefits
- Implements the scientifically-backed XKCD method that provides exponential security gains through word count.
- Uses the EFF Diceware list of 7,776 words — the same curated wordlist recommended by security researchers worldwide.
- Memorability leverages the brain's superior verbal and visual memory systems — you remember words, not characters.
- Each additional word multiplies the attacker's search space by 7,776, providing exponential security scaling.
Use Cases
Generating memorable passphrases for password manager master vaults that must be typed regularly.
Creating SSH key passphrases for developers who authenticate frequently to remote servers.
Building shared team passphrases for collaborative tool access during onboarding.
Producing recovery passphrases for two-factor authentication backup that must be reliably recalled.
Common Mistakes to Avoid
Using only 3 words which provides only 38.8 bits of entropy — crackable in under a second at 1 trillion hashes/second.
Choosing words that form meaningful sentences ('the cat sat on the mat') — this reduces the search space for dictionary attacks.
Substituting words with l33tsp34k variations ('c0rr3ct') — attackers automatically try these substitutions.
Using common words that appear in every XKCD passphrase list — the security comes from randomness, not word choice.
Security Implications
The XKCD method's security derives from combinatorial explosion: with 7,776 words, a 4-word passphrase has 3.7 × 10¹⁵ possible combinations, while a 6-word passphrase has 2.2 × 10²³. An attacker testing 1 trillion combinations per second would need 58.6 years for a 4-word passphrase and 7 billion years for a 6-word passphrase. The method is resistant to dictionary attacks because the EFF wordlist contains common English words that don't follow natural language patterns — 'correct horse battery staple' is grammatically correct by coincidence, but most random word combinations are not, preventing NLP-assisted attacks.
Security Information
Frequently Asked Questions
References & Further Reading
What is an XKCD Password Generator?
An XKCD password generator creates passphrases by combining random words, inspired by the famous XKCD comic strip "Password Strength" (comic #936). The comic explains that "correcthorsebatterystaple" is both easier to remember and harder to crack than "Tr0ub4dor&3". Our generator takes this concept further with customizable word counts, separators, and optional numbers/symbols.
XKCD-style passphrases use common English words selected randomly from a large wordlist. Each word adds approximately 12-13 bits of entropy (from a list of 7,776 words). A 4-word passphrase provides about 52 bits, while a 6-word passphrase provides about 78 bits of entropy. The strength comes from length and word diversity, not complexity.
How XKCD Password Generation Works
Our XKCD generator uses the EFF large wordlist with 7,776 carefully selected English words. Each word is chosen using crypto.getRandomValues() for cryptographically secure randomness. The entropy is calculated as: entropy = word_count x log2(7,776).
Word Selection: Words are randomly selected from the wordlist with uniform probability. The EFF wordlist was designed to maximize security and usability, with words chosen for being common, easy to spell, and distinct from one another.
Separators: Words can be joined with spaces, hyphens, dots, or no separator. Spaces are most readable; hyphens are more compact. The separator does not significantly affect security.
Enhancements: Optional capitalization, number appending, and symbol insertion add extra entropy. However, the base word selection provides the primary security, and these additions should not be relied upon for critical security.
Where XKCD Passphrases Excel
Master Passwords: XKCD passphrases are ideal for password manager master passwords. You need one extremely strong password that protects all your other credentials, and a 6-8 word passphrase provides that security while remaining memorable.
Disk Encryption: Full-disk encryption requires a strong passphrase that you can type from memory. XKCD passphrases provide the security of long random strings with the usability of real words.
Wi-Fi Networks: For WPA2/WPA3 personal mode, XKCD passphrases serve as strong network passwords that guests can easily type without errors.
SSH Keys: When protecting SSH private keys with a passphrase, XKCD-style passphrases provide strong protection while being practical to type regularly.
XKCD Passphrase Mistakes
Using Too Few Words: A 3-word passphrase provides only about 39 bits of entropy, which can be cracked in minutes. The XKCD comic itself recommends 4 words minimum, but 6+ words are recommended for modern security requirements.
Choosing Words Manually: The security depends entirely on randomness. If you select words yourself, your choices are predictable. Always let the generator pick the words randomly using cryptographic randomness.
Using Common Phrases: Avoid well-known phrases like "to be or not to be" or "the quick brown fox." These are in every attacker's dictionary. Random word combinations are essential.
Over-complicating with Symbols: Adding numbers and symbols provides marginal security improvement while reducing memorability. The base word selection provides the primary security.
Related Passphrase Tools
Explore these related passphrase and password generation tools:
- Passphrase Generator — Generate multi-word passphrases with various word selection methods.
- Diceware Generator — Generate Diceware passphrases using the EFF wordlist.
- Memorable Password Generator — Create memorable passwords with word-number combinations.
- Password Entropy Calculator — Calculate the entropy bits of your passphrase.
- Password Strength Checker — Test your passphrase strength against dictionary attacks.