Developer Guides

Cryptographic Hashing Explained: SHA-256 vs. SHA-512 vs. MD5 Collision Resistance & Checksum Guide

Try & Tool Cryptography & Security Team• Published: 2026-10-11• 11 min read
Understand one-way cryptographic hash functions. Discover why MD5 and SHA-1 are cryptographically broken, compare SHA-256 vs SHA-512 performance, verify software checksums, and generate HMAC webhook signatures.

What is a Cryptographic Hash Function?

A cryptographic hash function is a one-way mathematical algorithm that takes an arbitrary block of data (a plaintext password, an API payload, a Git commit, or a 4GB operating system ISO image) and transforms it into a fixed-length string of characters, called a digest or hash.

Cryptographic hashes are the foundation of blockchain transactions, digital signatures, TLS/SSL certificates, software release verification, and Git version control.

In this guide, we explain the four essential properties of cryptographic hashing, examine why legacy algorithms like MD5 fell to collision attacks, compare SHA-256 and SHA-512, and demonstrate how to verify file checksums and compute HMAC signatures.

Generate SHA-256, SHA-512, MD5, and HMAC hashes privately in your browser with our Hash Generator & Checksum Calculator.


The Four Essential Properties of Secure Hashing

To be considered cryptographically secure, an algorithm must satisfy four rigorous criteria:

  1. Determinism: The same input payload will ALWAYS produce the exact same output digest.
  2. Pre-Image Resistance (One-Way): Given a hash digest $H$, it is mathematically infeasible to reverse the function and calculate the original input $M$.
  3. The Avalanche Effect: Changing a single bit in the input completely randomizes the resulting digest:
    • sha256("password") -> 5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8
    • sha256("Password") -> e7cf3ef4f17c3999a9b31ab5292778a27bc9bba770e42d08563412f18e66ff11
  4. Collision Resistance: It must be computationally impossible to find two different input strings $M_1$ and $M_2$ that produce the identical hash digest: $$ ext{Hash}(M_1) eq ext{Hash}(M_2)$$

The Fall of MD5 and SHA-1: Why They Are Broken

In the 1990s and 2000s, MD5 (128-bit) and SHA-1 (160-bit) were the industry standards. Today, both are considered cryptographically broken:

  • MD5 Collisions (2004): Cryptanalyst Xiaoyun Wang demonstrated that MD5 collisions could be generated in hours on standard PCs. In 2012, the Flame cyber-espionage malware forged a fake Microsoft digital certificate using an MD5 collision to hijack Windows Update.
  • SHA-1 "SHAttered" (2017): Google and CWI Amsterdam produced two PDF documents with completely different visual contents that generated the identical SHA-1 hash after $9 imes 10^{18}$ computations.

Rule of Thumb: Never use MD5 or SHA-1 for digital signatures, password storage, or security tokens. MD5 remains useful only as an ultra-fast non-cryptographic checksum to verify accidental file corruption during downloads.


SHA-256 vs. SHA-512: Architectural Comparison

Both algorithms belong to the NIST SHA-2 family, but differ in word size and CPU performance:

SpecificationSHA-256SHA-512
Output Digest Length256 bits (64 hexadecimal characters)512 bits (128 hexadecimal characters)
Internal Word Size32-bit words64-bit words
State BlocksEight 32-bit variablesEight 64-bit variables
Rounds of Hashing64 rounds80 rounds
Collision Security$2^{128}$ operations$2^{256}$ operations
Performance on 64-bit CPUsModerate (~1.2 GB/s)~50% Faster on 64-bit hardware!

Because modern cloud servers (x86_64 and ARM64 / Apple Silicon) operate with native 64-bit registers, SHA-512 actually processes large file payloads faster than SHA-256!


Verifying Downloaded Software Checksums

When downloading an OS image, CLI utility, or zip file, verify its authenticity against the vendor's published checksum:

# Linux
sha256sum ubuntu-24.04-desktop.iso

# macOS
shasum -a 256 node-v22.0.0.pkg

# Windows PowerShell
Get-FileHash -Algorithm SHA256 .DockerDesktopInstaller.exe

Why You Should NEVER Use SHA-256 for Passwords

A common beginner mistake is hashing user passwords with raw SHA-256:

// ❌ CRITICAL SECURITY FLAW
const userHash = crypto.createHash('sha256').update(password).digest('hex');

Modern GPUs can compute over 10 billion SHA-256 hashes per second. An attacker with a leaked password database can brute-force 8-character passwords across billions of possibilities in minutes using precomputed rainbow tables.

For passwords, always use adaptive, memory-hard key derivation functions:

  • Argon2id (OWASP Recommended)
  • bcrypt (Work factor 12+)
  • scrypt or PBKDF2

Calculate hashes and verify file checksums privately in your browser with our Hash Generator & Checksum Calculator.