Cryptographic Hashes Explained: SHA-256 vs. SHA-512 vs. MD5 and Collision Resistance
A technical exploration of cryptographic hashes: the avalanche effect, pigeonhole principle, Merkle-Damgård construction, and SHA-256 algorithms.
Explore information theory entropy calculations, brute-force cracking resistance, cryptographic random number generators (CSPRNG), and passphrase security.
Privacy & Security technical reference asset
Authentication credentials remain the primary gateway safeguarding personal bank accounts, cloud infrastructure, and private communications. Yet, many users and legacy enterprise systems still rely on outdated password guidelines created decades ago.
In information theory, password strength is not measured by arbitrary punctuation rules or memorable mnemonics; it is mathematically quantified as information entropy (measured in bits). Understanding entropy allows developers and security analysts to build robust authentication systems resistant to modern distributed brute-force attacks.
Password entropy is a measurement of the unpredictability and randomness of a secret string, derived from Claude Shannon’s foundational work on Information Theory. It quantifies how many binary guesses (bits) an automated attacker would need to systematically test every possible permutation in the worst-case scenario.
Each additional bit of entropy doubles the total number of attempts required to exhaust the keyspace ($2^H$). A password with 60 bits of entropy requires $2^{60}$ (~1.15 quintillion) guesses to guarantee a brute-force match.
The entropy $H$ of a randomly generated string is calculated using the pool size $R$ (number of possible characters) and the string length $L$:
Formula: H = L × log2(R)
Where:
- H = Entropy in bits
- L = Length of the password
- R = Size of the character pool (keyspace per character)
Common Character Pool Sizes (R):
- Numbers only (0-9): R = 10 (log2(10) ≈ 3.32 bits/char)
- Lowercase letters (a-z): R = 26 (log2(26) ≈ 4.70 bits/char)
- Upper + Lowercase (a-z, A-Z): R = 52 (log2(52) ≈ 5.70 bits/char)
- Alphanumeric (a-z, A-Z, 0-9): R = 62 (log2(62) ≈ 5.95 bits/char)
- Full Printable ASCII (with symbols): R = 94 (log2(94) ≈ 6.55 bits/char)Modern offline password cracking rigs utilizing dedicated GPU arrays (such as eight NVIDIA RTX 4090 GPUs) can execute over 200 billion NTLM or MD5 hash evaluations per second.
| Password Example | Length & Character Set | Entropy (Bits) | Cracking Time (200B guesses/sec) |
|---|---|---|---|
| Summer2026! | 11 chars (Lower, Upper, Num, Sym) | ~36 bits (predictable dictionary pattern) | Under 1 second |
| 8k#M2$pQ | 8 chars (Full ASCII random) | ~52.4 bits | 22 minutes |
| X9#mK2$vL8!qZ3@p | 16 chars (Full ASCII random) | ~104.8 bits | 5.8 × 10¹³ years (Unbreakable) |
| correct horse battery staple | 4 random Diceware words | ~77.2 bits (2048-word list) | 3.4 × 10⁸ years (Audited secure) |
National Institute of Standards and Technology (NIST) Special Publication 800-63B officially discourages legacy composition rules (e.g., mandating at least one uppercase letter, one digit, and one special character).
When forced to include special symbols, humans predictably replace letters with obvious substitutions (e.g., "@" for "a", "!" at the end), which automated cracking tools anticipate via mask attacks. Increasing the length of a passphrase composed of 4 to 6 genuinely random dictionary words yields higher entropy while remaining easy for human users to remember.
Prioritize length over complex character substitution rules. A 16-character passphrase is exponentially more secure than an 8-character complex string.
When generating passwords or cryptographic keys in client-side software, developers must never use `Math.random()`. JavaScript’s `Math.random()` utilizes a pseudo-random number generator (PRNG) like Xoroshiro128+, which is deterministic and predictable.
Always use the Web Crypto API’s `crypto.getRandomValues()`, which interfaces with kernel-level hardware entropy sources (such as thermal noise and interrupt timings).
// ❌ Insecure: Math.random() is predictable
function insecureRandomChar(pool) {
return pool[Math.floor(Math.random() * pool.length)];
}
// ✅ Cryptographically Secure: Web Crypto API (CSPRNG)
function secureRandomPassword(length = 16) {
const charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()-_=+";
const randomBytes = new Uint32Array(length);
window.crypto.getRandomValues(randomBytes);
return Array.from(randomBytes)
.map((val) => charset[val % charset.length])
.join('');
}Key security questions answered:
By understanding information theory entropy and transitioning to long, cryptographically generated passphrases, individuals and organizations can effectively neutralize brute-force attacks and protect critical digital assets.
Try these free in-browser utilities mentioned in this guide
Calculate cryptographic hash sums (SHA-256, SHA-512, SHA-1, SHA-384, MD5) for text and files.
Generate cryptographically random UUID v4 and GUID identifiers in bulk with custom casing.
Encode text and binary files to Base64 format or decode Base64 data back into plaintext and files.
A technical exploration of cryptographic hashes: the avalanche effect, pigeonhole principle, Merkle-Damgård construction, and SHA-256 algorithms.
Explore native W3C crypto standards, SubtleCrypto interfaces, constant-time operations, and why pure JavaScript crypto libraries are obsolete.
Explore FIDO2/WebAuthn handshakes, asymmetric key pairs, hardware security enclaves (TouchID, FaceID, Windows Hello), and phishing-resistant authentication.