Difficulty: Beginner
Which is more secure: a short complex password or a long passphrase? What password policy would you implement for a new app?
A long passphrase is usually more secure. Strength comes mainly from length and randomness, and four to six randomly chosen words like correct-horse-battery-staple give more real entropy than a short password like P@ss12!, while being far easier to remember. Current NIST guidance (SP 800-63B) reflects this: favour length, drop forced complexity rules, and block known breached passwords instead.
Entropy measures how many guesses an attacker needs. For truly random choices it is length x log2(alphabet size):
| Password | How it is built | Approx. entropy |
|---|---|---|
P@ss12! | 7 chars from ~95 printable | ~46 bits if random, far less in practice |
| Random 12 chars | 12 chars from ~95 | ~79 bits |
| 4 random Diceware words | 4 picks from 7,776 words | ~52 bits |
| 6 random Diceware words | 6 picks from 7,776 words | ~78 bits |
The catch is "if random". Humans do not pick randomly. Complexity rules push people toward predictable patterns: capital first letter, a common word, @ for a, a year or 123 and ! at the end. Cracking tools like Hashcat apply exactly these rules to wordlists, so Flipkart@2025 falls quickly despite meeting every rule. Each word added to a passphrase multiplies the search space by the size of the wordlist, which helps much more than swapping a letter for a symbol.
A passphrase is only strong if the words are random. A famous quote or song lyric is in cracking wordlists.
NIST SP 800-63B (revision 4, finalized in 2025) recommends that services:
Summer2025! becoming Autumn2025!.| P@ss12! | correct-horse-battery-staple | |
|---|---|---|
| Length | 7 characters | 28 characters |
| Memorability | Hard to remember | Easy to remember |
| Typical crack method | Wordlist plus substitution rules | Needs word-level brute force |
| Strength driver | Symbol tricks | Number of random words |
import crypto from 'node:crypto';
async function isBreached(password) {
const sha1 = crypto.createHash('sha1').update(password).digest('hex').toUpperCase();
const prefix = sha1.slice(0, 5);
const suffix = sha1.slice(5);
// Only the 5-char prefix leaves your server
const res = await fetch(`https://api.pwnedpasswords.com/range/${prefix}`, {
headers: { 'Add-Padding': 'true' },
});
const body = await res.text();
return body.split('\n').some((line) => {
const [hashSuffix, count] = line.trim().split(':');
return hashSuffix === suffix && Number(count) > 0;
});
}
console.log(await isBreached('Password@123'));
The API returns all breached hash suffixes for that prefix and you match locally, so the full password hash is never sent. Padding hides the real response size.
import { zxcvbn } from '@zxcvbn-ts/core';
for (const pw of ['P@ss12!', 'Flipkart@2025', 'correct-horse-battery-staple']) {
const r = zxcvbn(pw);
console.log(pw.padEnd(30), 'score', r.score, '/ 4');
}
zxcvbn models dictionary words, patterns and substitutions the way crackers do, so it rates predictable 'complex' passwords low. Exact scores depend on the dictionaries loaded.
Password Entropy, Passphrases, NIST SP 800-63B, Breached Password Checks, Password Policy