ThisCalculator

Everyday

File Checksum Mac: Verify & Calculate Checksums

Updated · Standard formula, shown below

File Checksum Mac: Verify & Calculate Checksums

On a Mac, a file checksum is a short, fixed-length string (like e3b0c44298fc1c149afbf4c8996fb924) calculated from the file’s contents. You can verify or calculate it using the built-in Terminal commands md5, shasum, or cksum — no extra software needed. This article explains what checksums are, how to use them on macOS, and how to read the results.

What Is a Checksum and Why Does It Matter?

A checksum is a cryptographic fingerprint of a file. The algorithm (like MD5, SHA-1, or SHA-256) processes the file’s binary data and produces a fixed-size string. If even one bit changes — a corrupted download, a disk error, or tampering — the checksum changes drastically. This makes checksums useful for:

  • Verifying that a downloaded file matches the original (e.g., a software installer).
  • Checking that a file wasn’t corrupted during transfer or storage.
  • Confirming two files are identical without reading them byte-by-byte.

macOS includes several checksum tools in Terminal, so you rarely need to install third-party apps.

How to Calculate a Checksum on Mac (Terminal)

Open Terminal (in /Applications/Utilities/). Use one of these commands, replacing /path/to/file with your actual file path:

  • MD5: md5 /path/to/file — outputs the MD5 hash.
  • SHA-1: shasum -a 1 /path/to/file — outputs the SHA-1 hash.
  • SHA-256: shasum -a 256 /path/to/file — outputs the SHA-256 hash (most common for modern downloads).
  • All SHA variants: shasum -a 512 /path/to/file for SHA-512, etc.
  • POSIX checksum: cksum /path/to/file — outputs a CRC checksum and byte count (less secure, rarely used for verification).

For example, to verify a downloaded ISO, you might run:

shasum -a 256 ~/Downloads/ubuntu-24.04.iso

The terminal prints the hash followed by the file path. Compare this hash to the official one published on the software’s website.

How to Verify a Checksum on Mac (Comparing Hashes)

Verifying means comparing the calculated hash with the expected hash. You can do this manually or with a command:

  1. Manual comparison: Copy the expected hash from the website, run the checksum command, and visually compare the first few and last few characters. It’s safer to compare the entire string.
  2. Using shasum with a file: Save the expected hash in a text file (e.g., SHA256SUMS) and run shasum -a 256 -c SHA256SUMS. The command will output OK or FAILED.
  3. Using md5 with -q: For MD5, you can use md5 -q file to output only the hash (no file name) for easier copying.

If the hashes don’t match, the file is different — do not use it if it’s a software installer or a security-critical file. Re-download it from a trusted source.

Which Algorithm Should You Use?

For most verification purposes, SHA-256 is the recommended choice. It’s widely used, fast, and cryptographically secure. Here’s a quick guide:

  • MD5: Fast but no longer considered secure against deliberate tampering. Still used for quick integrity checks (e.g., checking a file wasn’t corrupted in transit).
  • SHA-1: Also deprecated for security, but still common in older systems.
  • SHA-256 / SHA-512: Secure and recommended. Most download sites publish SHA-256 hashes.

If a website offers multiple hashes, pick the strongest one (SHA-256 or SHA-512). If only MD5 is given, it’s better than nothing but not tamper-proof.

Common Problems and Pitfalls

Users often run into these issues when checking checksums on a Mac:

  • Wrong file path: If you get No such file or directory, drag the file into the Terminal window after typing the command — it will insert the correct path.
  • Line breaks in the expected hash: When copying a hash from a website, make sure you don’t include extra spaces or line breaks. Use pbcopy to copy the hash, then compare with a command like pbpaste | grep -i "hash" (advanced).
  • Case sensitivity: Hashes are usually lowercase hexadecimal. If the website shows uppercase, it’s fine — just compare case-insensitively.
  • File changes during download: If the hash doesn’t match, the download may be incomplete or corrupted. Delete and re-download.
  • Using the wrong algorithm: Make sure you’re using the same algorithm as the published hash. SHA-256 hash will not match an MD5 hash.

Alternatives to Terminal: GUI Tools

If you prefer a graphical interface, several free apps can calculate checksums on macOS. These are not built-in, but they are widely used:

  • Checksum (by MacPaw): A simple drag-and-drop app that shows MD5, SHA-1, SHA-256, and more.
  • HashTab: Adds a “Checksumsâ€� tab to the Get Info window (requires system extension).
  • RapidCRC: Focused on CRC and MD5, often used for ROMs.

These tools are convenient, but the Terminal commands are just as reliable and always available.

Frequently Asked Questions

How do I check a file checksum on Mac without Terminal?

You can use a third-party app like Checksum or HashTab. These provide a drag-and-drop interface and display multiple hash types instantly. However, the Terminal commands are built-in and require no installation.

What is the difference between MD5 and SHA-256?

MD5 produces a 128-bit hash (32 hex characters) and is faster but vulnerable to collisions. SHA-256 produces a 256-bit hash (64 hex characters) and is cryptographically secure. For verifying downloads, use SHA-256 if available.

Why does the checksum change when I re-download the same file?

If the checksum changes, the file content is different. This could be due to a corrupted download, a different version of the file, or tampering. Always download from the official source and compare against the published hash.

Can I calculate a checksum for a folder?

Yes, but not directly with a single command. You can create a tar archive of the folder and checksum that, or use find to hash each file individually. For example: find /path/to/folder -type f -exec shasum -a 256 {} \; will list hashes for each file.

Is it safe to use MD5 checksums?

For verifying accidental corruption, MD5 is fine. For security against intentional tampering, MD5 is not secure — use SHA-256 or higher. Many download sites still offer MD5 for convenience, but prefer SHA-256 when available.

What does “checksum mismatch� mean?

It means the calculated hash does not equal the expected hash. The file is either corrupted, incomplete, or not the same as the one the hash was generated from. Do not use the file if it’s a critical installer or document.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.