EduSupport Logo

EduSupport

Security
Hashing
CS

MD5 vs SHA-256: Hashing Explained for Students

Jul 23, 2026

5 min read

What a Hash Function Does

A hash function takes any input — a password, a file, the complete works of Shakespeare — and produces a fixed-size fingerprint called a hash or digest. Three properties make this useful:

  1. Deterministic — the same input always produces the same hash.
  2. One-way — you cannot reverse a hash back into its input.
  3. Avalanche effect — change one character of the input and the hash changes completely.

See it yourself in the free Hash Generator: hash the word hello, then hash Hello. One capital letter, and every character of the output is different. That sensitivity is the point — a hash is a tamper-evident seal for data.

Hashes are everywhere: verifying downloaded files, storing passwords, Git commit IDs, blockchain blocks, and digital signatures all rest on hash functions.

MD5: Fast, Famous, and Broken

MD5 (1992) produces a 128-bit hash — 32 hex characters. For a decade it was the hash function. Then cryptographers broke it.

The fatal flaw is collisions: two different inputs that produce the same MD5 hash. A secure hash function makes finding collisions computationally infeasible. For MD5, researchers demonstrated practical collisions in 2004; today a laptop finds one in seconds. Attackers have exploited this in the real world — most famously, the Flame malware used an MD5 collision to forge a Microsoft code-signing certificate.

What collision weakness means practically: an attacker can craft a malicious file with the same MD5 hash as a legitimate one. The tamper-evident seal can be forged.

Is MD5 ever acceptable? For non-security uses only — cache keys, hash-table bucketing, quick duplicate detection where no attacker exists. The moment integrity or security matters, MD5 is disqualified.

SHA-256: The Current Standard

SHA-256 belongs to the SHA-2 family (2001) and produces a 256-bit hash — 64 hex characters. No practical collision or preimage attack against it is known, and it is the workhorse of modern security: TLS certificates, operating-system package verification, Bitcoin, and government standards (NIST) all use it.

MD5SHA-256
Output size128 bits (32 hex chars)256 bits (64 hex chars)
Year introduced19922001
Collisions found?Yes — trivially, since 2004None known
Safe for security use?NoYes
SpeedFasterFast enough (hardware-accelerated on modern CPUs)
Use todayNon-security fingerprinting onlyChecksums, signatures, integrity, certificates

MD5's remaining advantage — raw speed — is irrelevant for security purposes and actively harmful for passwords, as the next section explains.

The Password Twist: Fast Hashes Are the Wrong Tool

Here is the nuance that separates a good answer from a great one in a security course: SHA-256 alone is also wrong for passwords — for the opposite reason MD5 is wrong for signatures.

General-purpose hashes are designed to be fast. But when a database of hashed passwords leaks, speed helps the attacker: a modern GPU computes billions of SHA-256 hashes per second, brute-forcing every common password in minutes.

Password storage therefore uses deliberately slow, salted algorithms — bcrypt, scrypt, or Argon2 — which are tunably expensive to compute, and which add a unique random salt per password so identical passwords produce different hashes and precomputed "rainbow tables" are useless.

The hierarchy to remember:

  • File integrity / checksums → SHA-256
  • Passwords → bcrypt / Argon2 (never bare MD5 or bare SHA-256)
  • Nothing security-related → MD5 is tolerable, SHA-256 still preferable

Verifying a File Checksum in Practice

You will do this constantly as a developer. A site publishes a SHA-256 checksum next to its download; after downloading, you hash the file locally and compare:

# macOS / Linux
shasum -a 256 downloaded-installer.dmg

# Windows PowerShell
Get-FileHash downloaded-installer.exe -Algorithm SHA256

If your computed hash matches the published one character-for-character, the file arrived intact and untampered. If even one character differs, do not run the file.

For quick text-based experiments — comparing algorithm outputs, checking what a hash of your input looks like, or completing a coursework exercise — the Hash Generator computes MD5, SHA-1, SHA-256, and SHA-512 side by side, entirely in your browser.

Exam-Ready Summary

  • Hashing is one-way fingerprinting; encryption is two-way and needs a key — do not confuse them (and neither is Base64, which is just encoding).
  • MD5 is cryptographically broken via practical collisions — never use it where an attacker might exist.
  • SHA-256 is the current standard for integrity and signatures.
  • Passwords need slow, salted algorithms (bcrypt/Argon2) — a fast hash, even a secure one, is the wrong tool.

If a security or cryptography assignment goes deeper than this — implementing hash functions, analyzing attacks, or building authentication — the programming help service at EduSupport can connect you with developers who can walk you through it, concept by concept.


Need one-on-one academic support?

Our expert team is available 24/7 for assignments, projects, and exam prep.

More Articles
Base64
CS
What Is Base64 Encoding and When Should You Use It?
5 min read
Regex
Programming
Regex for Beginners: A Practical Guide With Examples
5 min read
MD5 vs SHA-256: Hashing Explained | EduSupport