Password Complexity

Difficulty: Beginner

Question

Which is more secure: a short complex password or a long passphrase? What password policy would you implement for a new app?

Answer

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.

Why length beats complexity

Entropy measures how many guesses an attacker needs. For truly random choices it is length x log2(alphabet size):

PasswordHow it is builtApprox. entropy
P@ss12!7 chars from ~95 printable~46 bits if random, far less in practice
Random 12 chars12 chars from ~95~79 bits
4 random Diceware words4 picks from 7,776 words~52 bits
6 random Diceware words6 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.

What modern guidance says

NIST SP 800-63B (revision 4, finalized in 2025) recommends that services:

  • Require a minimum of 15 characters when the password is the only factor, and at least 8 when it is used with MFA.
  • Allow at least 64 characters and accept spaces and all printable Unicode.
  • Not impose composition rules like "one uppercase, one digit, one symbol".
  • Not force periodic password changes; require a change only on evidence of compromise.
  • Check new passwords against lists of breached, common and context-specific values (the app name, the username).
  • Allow paste and password managers.

A sensible policy for a new app

  1. Minimum length (15 if password-only, lower with MFA), generous maximum.
  2. Block breached passwords using the Have I Been Pwned range API, which uses k-anonymity so you send only the first 5 hex characters of the SHA-1 hash.
  3. Show a strength meter based on a real estimator like zxcvbn, not on character classes.
  4. Rate limit and lock out progressively on failed logins.
  5. Offer MFA and passkeys; passkeys remove the phishing and reuse problem entirely.
  6. Store with Argon2id or bcrypt, never a fast hash.

Common misconceptions

  • Complexity rules do not make users safer; they make passwords harder to remember and lead to reuse and sticky notes.
  • Forced 90-day rotation leads to Summer2025! becoming Autumn2025!.
  • Password strength matters less than reuse. The most common real attack is credential stuffing with passwords leaked from another site.
Complex password vs passphrase. Length and real randomness matter more than symbol substitutions.
P@ss12!correct-horse-battery-staple
Length7 characters28 characters
MemorabilityHard to rememberEasy to remember
Typical crack methodWordlist plus substitution rulesNeeds word-level brute force
Strength driverSymbol tricksNumber of random words

Code examples

Checking a password against Have I Been Pwned (k-anonymity)

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.

Estimating strength with zxcvbn

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.

Key points

  • Length and randomness drive strength; symbol substitutions add little
  • A passphrase must use randomly chosen words, not a quote or lyric
  • NIST SP 800-63B: no composition rules, no forced rotation, check breached lists
  • Block breached passwords with the HIBP k-anonymity range API
  • MFA and passkeys matter more than any password rule

Common follow-up questions

  • How does the Have I Been Pwned range API protect user privacy?
  • Why does NIST advise against periodic password rotation?
  • What is credential stuffing and how would you defend against it?
  • How do passkeys remove the need for strong passwords?

Interview tips

  • Show the entropy reasoning briefly, then explain why humans are not random
  • Citing the current NIST guidance on composition rules and rotation shows you are up to date
  • Round off with MFA, passkeys and breached-password checks rather than only length rules

Concepts covered

Password Entropy, Passphrases, NIST SP 800-63B, Breached Password Checks, Password Policy

More Web Security (OWASP, JWT, XSS, CSRF) questions