Back to all guides

Cryptographic Hashing: MD5, SHA-256, and Password Security Explained

Understand how one-way cryptographic hash functions work, why MD5 is obsolete, and how salted hashing protects stored credentials.

DK
Dipanshu Kumar
Founder & Software Architect at Tool Yaar
Updated: 2026-11-069 min read

What Is a Cryptographic Hash Function?

A cryptographic hash function is a mathematical algorithm that maps an arbitrary, variable-length block of input data (whether a 5-letter word or a 10 GB operating system ISO image) into a fixed-length string of characters, called a hash value, digest, or checksum.

Crucially, cryptographic hashing is strictly a one-way mathematical function. While it is trivial to compute the hash digest from an input file, it is computationally impossible to reverse the process and reconstruct the original input from the resulting digest.

The Four Fundamental Rules of Cryptographic Hashes

To be classified as cryptographically secure, a hashing algorithm must satisfy four rigorous criteria:

  • Deterministic Output: The exact same input will always produce the identical hash digest, regardless of when or where it is calculated.
  • Pre-image Resistance (One-Way): Given a target hash digest H, it is computationally infeasible to find any original input M such that hash(M) = H.
  • Second Pre-image Resistance: Given an input M1, it is impossible to find a different input M2 such that hash(M1) = hash(M2).
  • Collision Resistance: It is impossible to find any two arbitrary, distinct inputs that happen to produce the same hash digest.
  • The Avalanche Effect: Changing a single bit in the input (e.g., turning a lowercase letter into uppercase) dramatically and unpredictably changes over 50% of the output digest characters.

Why MD5 and SHA-1 Are Cryptographically Broken

In the 1990s and early 2000s, MD5 (Message Digest 5, 128-bit) and SHA-1 (160-bit) were widely deployed across security protocols. However, advances in cryptanalysis and GPU computing demonstrated severe structural collision vulnerabilities.

In 2004, researchers proved that two completely different PDF contracts could be engineered to yield the exact identical MD5 hash. In 2017, Google announced the SHAttered attack, generating two distinct PDF files with the same SHA-1 digest. Today, MD5 and SHA-1 must never be used for digital signatures, SSL certificates, or security credentials.

MD5 Is Obsolete for Security

Never use MD5 or SHA-1 for passwords, digital signatures, or security tokens. They are only acceptable for non-cryptographic cache keys or checksum validation against accidental file corruption.

SHA-256 & SHA-3: The Modern Gold Standard for Data Integrity

Designed by the United States National Security Agency (NSA) and standardized by NIST, the SHA-2 family—specifically SHA-256 (256-bit digest)—remains the global gold standard for cryptographic integrity.

SHA-256 powers the Bitcoin blockchain, TLS/SSL website security certificates, Git commit trees, and software download checksums. To date, there is no known practical collision attack against SHA-256.

The Fatal Mistake: Fast Hashes vs Slow Password Hashes

A pervasive mistake among junior software developers is using fast cryptographic hashes (like raw SHA-256) to store user passwords in databases. Because SHA-256 was designed for high-throughput file checksums, modern consumer graphics cards (GPUs) can compute over 10 billion SHA-256 hashes per second.

If an attacker steals a database of unsalted SHA-256 hashes, they can precompute "rainbow tables" or brute-force typical 8-character passwords in minutes.

Passwords must always be hashed using deliberately slow, memory-hard key derivation functions: Bcrypt, PBKDF2 (with high iteration counts), or Argon2. These algorithms force attackers to expend extensive CPU and memory resources, rendering brute-force attacks mathematically infeasible.

Cryptographic Hashing Algorithm Comparison

Summary of common hashing functions and their contemporary security posture:

AlgorithmDigest SizeCollision StatusPrimary Modern Use Case
MD5128 bitsBroken (instant collisions)Legacy non-security file checksums only
SHA-1160 bitsBroken (SHAttered attack)Phased out; avoid in all new systems
SHA-256256 bitsSecure (no known collisions)TLS certificates, Git, software integrity, blockchain
SHA-512512 bitsSecure (highly resilient)High-security government & enterprise integrity
Bcrypt / Argon2VariableSecure (adaptive work factor)User password storage and authentication

Frequently Asked Questions

Q:Can you decrypt a SHA-256 hash back to the original text?

No. Hashing is fundamentally irreversible. There is no mathematical "key" that decrypts a hash because data is deliberately compressed and discarded during the process.

Q:What is a cryptographic "Salt"?

A salt is a unique, cryptographically random string appended to a password before hashing. Salting ensures two users with identical passwords will have completely different stored hashes, defeating precomputed rainbow table attacks.

Q:Why does Git use SHA hashes for commits?

Git uses SHA hashes (historically SHA-1, transitioning to SHA-256) to uniquely identify every commit, tree, and file blob based entirely on its contents, creating an immutable history graph.

Q:How do I verify a software download checksum using SHA-256?

On Windows, open PowerShell and run `Get-FileHash setup.exe -Algorithm SHA256`. On macOS and Linux, run `shasum -a 256 setup.exe` and compare the output string against the developer’s published hash.

Interactive Tools

Try the Free Tools Mentioned in this Guide

DK
About the Author

Dipanshu Kumar

Dipanshu is the founder and lead software architect of Tool Yaar. He designs high-performance client-side web utilities, WebAssembly engines, and offline Android tools focused on zero-upload user privacy and universal digital accessibility.