All Articles

Measuring Password Strength Properly: Shannon Entropy, CSPRNG vs. Math.random(), and 6-Word Diceware

Measuring Password Strength Properly: Shannon Entropy, CSPRNG vs. Math.random(), and 6-Word Diceware
Photo: Sendly Team / Unsplash

Legacy signup forms still train users to create weak credentials by grading passwords purely on checkbox rules: one uppercase letter, one number, and one symbol. Under those naive rules, Winter2026! scores 100% "Strong"—yet modern GPU cracking rigs guess it in seconds. Measuring password strength accurately requires Shannon entropy analysis, pattern-walk penalties, and generators backed by a true hardware-seeded CSPRNG.

Key Takeaways

TL;DR: Real credential resistance comes from large, unbiased random keyspaces rather than predictable symbol swaps (@ for a). Browser password generators must replace Math.random() with window.crypto.getRandomValues() using rejection sampling to eliminate modulo bias.

1. Why Composition Checkboxes Create False Security

Human brains are notoriously poor sources of randomness. When forced to satisfy arbitrary character rules, people converge on identical structural templates: capitalized dictionary word + current year + trailing exclamation mark ([Word][202x][!]), or QWERTY keyboard walks (1qaz2wsx!Q).

Modern password-recovery and cracking tools like Hashcat do not test strings randomly character by character. Instead, they execute rule-based mutations across leaked credential corpuses—capitalizing initial letters, appending 2024–2026, and swapping e → 3 or s → $ at billions of candidates per second on consumer RTX GPUs.

Pattern-Aware Entropy Auditing

To measure real-world cracking resistance instead of theoretical maximums, an auditor evaluates multiple layers locally in browser memory:

  • Shannon Information Entropy: Measures symbol unpredictability across character frequencies (H = -Σ p(i) log₂ p(i) × length), exposing repeated padding like aaaaBBBB!!!! that inflates length without adding genuine randomness.
  • Keyboard Geometry Detection: Scans horizontal rows (qwerty), vertical columns (qazwsx), and numeric keypad sequences (147258) forward and backward.
  • Root Dictionary Normalization: Strips numeric suffixes and l33tspeak substitutions before testing substrings against compromised word roots.

2. Why JavaScript Generators Must Never Use Math.random()

If you inspect casual password generator tutorials online, many still generate characters using charset[Math.floor(Math.random() * charset.length)]. In security engineering, this fails on two fundamental levels:

  1. Non-Cryptographic PRNG State: JavaScript's Math.random() uses fast algorithms (such as Xorshift128+) optimized for frame rendering and UI jitter. It makes zero unpredictability guarantees against attackers who observe prior outputs.
  2. Modulo Distribution Bias: Even if you pull random bytes from Web Crypto, doing byte % charset.length skews probability slightly toward early characters whenever 256 (or 2³²) is not evenly divisible by the character pool size.

Eliminating Modulo Bias With Rejection Sampling

A production-grade browser generator reads 32-bit unsigned integers from window.crypto.getRandomValues() (which hooks directly into the OS CSPRNG) and discards values above the largest clean multiple of the pool size:

function cryptoRandomIndex(poolSize) {
  const UINT32_RANGE = 0x100000000; // 2^32
  const maxUnbiased = UINT32_RANGE - (UINT32_RANGE % poolSize);
  const buffer = new Uint32Array(1);
  let candidate;
  do {
    window.crypto.getRandomValues(buffer);
    candidate = buffer[0];
  } while (candidate >= maxUnbiased);
  return candidate % poolSize;
}

Because every remainder modulo poolSize appears the exact same number of times below maxUnbiased, each character or Diceware word is chosen with mathematically uniform probability.

3. Random Character Strings vs. Uniform Diceware Passphrases

High-entropy secrets do not always have to look like 9#kP!v2@Lm$8xQ*z. When memorizing a master vault key, laptop disk passphrase, or typing a decryption password manually on mobile, independent random words drawn uniformly from a large vocabulary outperform short symbol-heavy passwords:

Credential Format Pool / Search Space Entropy Bits Ideal Use Case
8-Char Mixed Human Pattern Heavily biased dictionary rules < 28 bits effective Unsafe for any sensitive account
4-Word Random Diceware (EFF 7,776 list) 7,776⁴ (~3.6 × 10¹⁵) ~51.7 bits Quick temporary encrypted file transfers
6-Word Random Diceware (EFF 7,776 list) 7,776⁶ (~2.2 × 10²³) ~77.5 bits Master password manager vault, full-disk encryption
16-Char CSPRNG String (94 ASCII symbols) 94¹⁶ (~3.7 × 10³¹) ~104.9 bits Unique stored logins, database credentials, API keys

4. Why Backend Hashing Costs Change Realistic Crack Times

Even with identical entropy bits, cracking speed varies by orders of magnitude depending on how a service stores or derives the key from your password:

  • Online Throttled Login (100 tries / hour): Rate limits, CAPTCHAs, and account lockouts stall guesses dramatically—meaning even 50+ bits can take decades against live web logins, though credential stuffing still succeeds if you reuse leaked passwords.
  • Leaked Fast Hash (MD5 / unsalted SHA-1 / legacy EvpKDF): Offline GPU clusters test tens of billions of guesses per second, tearing through any password under 45 bits in minutes or hours.
  • Memory-Hard KDF (Argon2id / scrypt / high-cost bcrypt): Memory bandwidth bottlenecks keep offline GPU rates orders of magnitude lower, giving well-chosen 6-word Diceware passphrases centuries of practical safety.

Three Rules That Beat Every Cracking Heuristic

  1. Never Reuse Credentials: A password reused across sites dies the moment the weakest site gets breached.
  2. Prefer Length Over Clever Substitutions: Adding two more random Diceware words adds ~25.8 bits of true entropy—far stronger than memorizing complex 8-character symbol rules.
  3. Keep Audits Client-Side: Always check entropy, patterns, and leaked suffixes locally so you never hand fresh plaintext passwords to third-party logging servers.

5. Safe Password Auditing Without Exposing Plaintext Secrets

Never paste a real password into an unfamiliar website that transmits form inputs to a backend server. Modern browser tools evaluate entropy, brute-force time estimates across online throttled vs. RTX 4090 GPU rigs, and pattern weaknesses strictly in local RAM—while checking breach exposure using zero-knowledge 5-character SHA-1 prefixes.

Test your passphrases privately or generate bias-free CSPRNG strings and memorable Diceware keys right inside Sendly Password Auditor. For a deeper look at how the optional breach-lookup protocol preserves complete privacy over the wire, read our dedicated guide on k-Anonymity SHA-1 Prefix Checking.

Privacy-First Browser Suite

Try Sendly tools with zero sign-up

Transfer files peer-to-peer, sync collaborative notes live, or share your screen straight from any browser tab.

Open P2P TransferLive NotepadScreen Share

Continue Reading

Browse all articles
JWT Security Pitfalls: Why "alg: none", Weak Secrets, and Public Token Debuggers Put APIs at Risk
Security4 min read

JWT Security Pitfalls: Why "alg: none", Weak Secrets, and Public Token Debuggers Put APIs at Risk

Browser-Side File Encryption Explained: AES-256-CBC, EvpKDF Key Derivation, and What Remains Unencrypted
Cryptography6 min read

Browser-Side File Encryption Explained: AES-256-CBC, EvpKDF Key Derivation, and What Remains Unencrypted

PREVIOUS ARTICLEPREVIOUS
From 5,000-Line JSON Blobs to Interactive Node Graphs: Visualizing Deep API Payloads in the Browser

Every backend and frontend engineer knows the frustration: a production webhook, Kubernetes manifest, or GraphQL response dumps 5,000 lines of JSON onto your sc...