HomeBlogHow to Verify File Integrity Using SHA & MD5 Hashes — Complete Guide
Security & Privacy2026-07-12⏱️ 8 min read

How to Verify File Integrity Using SHA & MD5 Hashes — Complete Guide

What Is a Hash Function?

A hash function takes an input of any size — a file, a string, a password — and produces a fixed-length string of characters called a hash, digest, or checksum. The same input always produces the same output, but even a single-bit change in the input produces a completely different hash. This makes hashes ideal for verifying that a file is exactly what the publisher intended — no more, no less.

Hashing is a one-way process: you can't reconstruct the original file from its hash, which is what makes it useful for both integrity checks and secure password storage (though, as covered below, raw hashing alone isn't enough for passwords).

Why Verify File Integrity With a Hash?

When you download software, especially from mirrors, torrents, or third-party sites, the file can be altered in two ways:

  • Accidental corruption — an interrupted download, a bad network connection, or a faulty storage medium can silently corrupt bytes.
  • Malicious tampering — an attacker intercepts the download and swaps the file for a modified version containing malware.

Publishers of serious software (Linux distributions, security tools, open-source projects) publish the official hash of each release file alongside the download link. If the hash you compute locally matches the published one, you can be confident the file arrived intact and unmodified.

MD5 vs SHA-1 vs SHA-256 vs SHA-512 — What's the Difference?

Not all hash algorithms are equal, and choosing the right one matters:

AlgorithmOutput LengthStatus
MD532 hex characters (128 bits)Cryptographically broken — avoid for security
SHA-140 hex characters (160 bits)Also broken — deprecated for security use
SHA-25664 hex characters (256 bits)Current industry standard
SHA-512128 hex characters (512 bits)Stronger, slightly slower, used where extra margin is wanted

MD5 and SHA-1 are still widely used for simple file integrity checks (catching accidental corruption) because collisions require deliberate, sophisticated effort to engineer — but neither should be trusted where security against a malicious actor matters. If you're verifying a file against a checksum published by a security-conscious source, prefer SHA-256 whenever it's offered.

How to Generate a Hash for File Verification

The easiest way to check a hash without touching the command line is to paste the relevant text (or the file's expected checksum) into a browser-based tool. The Hash Generator computes MD5, SHA-1, SHA-256, SHA-384, and SHA-512 hashes instantly, entirely inside your browser — nothing is uploaded to a server, which matters if the content you're hashing is sensitive.

If you need to hash the actual file content rather than text, use your operating system's built-in tool (below) to generate the hash, then paste that resulting hash string into the Hash Generator or a text comparison tool to check it against the one published by the file's source.

How to Check a File's Hash on Windows

Windows includes a built-in utility called certutil that can compute hashes without installing anything extra:

certutil -hashfile "C:\path\to\file.exe" SHA256

Replace SHA256 with MD5, SHA1, or SHA512 depending on which algorithm the publisher provided. The command returns the hash directly in the terminal — compare it character by character with the official value.

How to Check a File's Hash on macOS and Linux

macOS and Linux both ship with dedicated hashing commands:

shasum -a 256 /path/to/file
md5 /path/to/file          # macOS
md5sum /path/to/file       # Linux

The -a 256 flag tells shasum to use SHA-256; you can substitute 1, 384, or 512 for other algorithms. On Linux, sha256sum, sha1sum, and sha512sum are also available as standalone commands.

Step-by-Step: Verifying a Downloaded File

  1. Find the official checksum published by the file's source — usually on the download page or in a separate .sha256 / checksums.txt file.
  2. Run the matching hashing command for your operating system (see above) on the downloaded file.
  3. Compare the resulting hash to the published one, character by character. Even a single differing character means the file doesn't match.
  4. If the hashes match, the file is intact and identical to what the publisher released. If they don't match, delete the file and re-download it from a trusted source — don't run it.

What Is a Checksum?

A checksum is simply a hash value used specifically to confirm that data hasn't changed — the terms are often used interchangeably in the context of file downloads. Software distributors publish checksums (usually SHA-256 today) precisely so users can perform the verification steps above without needing any special tools beyond what's already built into their OS or a browser-based hash generator.

Is Hashing Reversible?

No. A properly designed cryptographic hash function is a one-way operation — there's no mathematical way to recover the original input from its hash alone. This is intentional and is exactly what makes hashes useful for both integrity verification and secure credential storage.

What Is a Hash Collision?

A collision occurs when two different inputs produce the same hash output. Every hash function technically allows collisions to exist mathematically (since inputs are infinite and outputs are fixed-length), but a secure algorithm makes finding one computationally infeasible. MD5 and SHA-1 have both had practical collision attacks demonstrated, which is why security professionals no longer consider them safe for anything beyond casual integrity checks against accidental corruption.

Can I Use Hashing for Passwords?

Raw SHA-256 or SHA-512 should never be used to store passwords directly, because these algorithms are designed to be fast — which makes them easy for attackers to brute-force at scale using modern hardware. For passwords, use a purpose-built algorithm like bcrypt, argon2, or PBKDF2, which are deliberately slow and include built-in salting to defend against rainbow table attacks.

What Is Salting?

Salting means adding a unique random value to each input before hashing it, so that even identical inputs (like two users with the same password) produce different hashes. This defeats precomputed rainbow table attacks, since an attacker would need a separate table for every possible salt value rather than one universal table.

What Is HMAC?

HMAC (Hash-based Message Authentication Code) combines a hash function with a secret key to verify both the integrity and the authenticity of a message — confirming not just that the data wasn't altered, but that it came from someone who holds the secret key. It's widely used in API authentication, where a server needs to confirm that a request came from a legitimate client and wasn't tampered with in transit.

Quick Reference: Which Hash Should You Use?

  • Verifying a downloaded file against a publisher's checksum → use whatever the publisher provides; prefer SHA-256 if multiple options are listed.
  • Detecting duplicate files or content → MD5 or SHA-256 both work fine, since security isn't the concern here.
  • Storing passwords → never raw SHA/MD5; use bcrypt, argon2, or PBKDF2.
  • Verifying API request authenticity → HMAC with SHA-256.

Conclusion

Hash verification takes seconds and can save you from running corrupted or malicious software. Whether you use your operating system's built-in command-line tools or a quick browser-based option, the process is the same: generate the hash, compare it to the official one, and only proceed if they match exactly. Try the free Hash Generator to compute MD5, SHA-1, SHA-256, SHA-384, and SHA-512 hashes instantly — everything runs locally in your browser, so nothing you hash ever leaves your device.