Digital Tutorials 5 min read

How to Check SHA-256 File Hashes on Windows, macOS, and Linux

Learn how to verify SHA-256 file hashes on Windows, macOS, and Linux to detect changes or corrupted downloads, and understand its limitations.

How to Check SHA-256 File Hashes on Windows, macOS, and Linux

When downloading applications, archives, or important files, file size and visible filenames aren’t enough to confirm that what you received matches what the publisher provided. One way to verify file integrity is to compare hash values, such as SHA-256. This check is relatively straightforward because Windows, macOS, and Linux include built-in tools or commonly available utilities.

A hash doesn’t guarantee a file is malware-free. Its purpose is to generate a digital fingerprint of the file’s contents, allowing us to compare it against a trusted reference value. This guide explains the concept, the commands you can use, and mistakes to avoid.

What Is SHA-256 Hash?

A cryptographic hash is a fixed-size result calculated from input data. SHA-256 is a member of the Secure Hash Algorithm 2 family and produces a 256-bit value, typically displayed as 64 hexadecimal characters. Even a small change to a file’s contents usually produces a drastically different hash value.

Because the result is determined by the file’s contents, two truly identical copies should produce the same SHA-256 hash. Conversely, if a file changes due to a corrupted download, modification, or replacement, the result will likely differ. This verification process is called integrity checking.

When Is SHA-256 Checking Useful?

  • Verifying downloads: ensuring the received file matches the hash value published by the developer.
  • Comparing copies: checking whether files on two devices have identical contents.
  • Validating archives or backups: helping detect changes after files are copied or moved.
  • Supporting troubleshooting: determining whether a file changed after transfer or storage.

For operating system installations, software, or sensitive administrative tools, hash verification can serve as an additional step before using the file.

How to Check SHA-256 on Windows

Windows includes a command-line utility called Get-FileHash available through PowerShell. No additional software installation is needed for basic checks.

  1. Download the file and note its location, such as the Downloads folder.
  2. Open Windows PowerShell or Windows Terminal.
  3. Run the following command, replacing the example path with your file’s location:
Get-FileHash "$HOMEDownloadsinstaller.exe" -Algorithm SHA256

PowerShell will display the algorithm, hash, and file path. Copy the value in the Hash column, then compare it against the official value provided by the publisher. Ensure the file path is correct; if the file is in a different folder, adjust the name and location accordingly.

To check another file, simply replace installer.exe with the appropriate filename. This command only reads and calculates the file’s hash—it doesn’t execute the file.

How to Check SHA-256 on macOS

macOS provides the shasum command in Terminal for calculating SHA-256. Open Terminal, then run:

shasum -a 256 ~/Downloads/installer.dmg

The output will show the hash value followed by the file path. If the filename contains spaces, enclose the path in quotes, for example shasum -a 256 "~/Downloads/installer terbaru.dmg". Alternatively, type the command first, add a space, then drag the file from Finder into the Terminal window to automatically insert its path.

How to Check SHA-256 on Linux

Most Linux distributions include the sha256sum utility. Open a terminal, navigate to the file’s directory if needed, then run:

sha256sum installer.tar.gz

For a file in the Downloads folder, for example:

sha256sum ~/Downloads/installer.tar.gz

The output typically contains the hash and filename. Some environments provide alternative tools, but use SHA-256 consistently so results can be compared against reference values using the same algorithm.

How to Compare the Results?

Find the official hash on the developer’s website or relevant download page. Compare all characters, not just the first few. If all characters match, this indicates the file contents align with those represented by that reference value—assuming the reference value itself is authentic.

If the results differ, don’t run the file immediately. Check whether you’ve selected the correct file, whether the reference value is for the same version and operating system, and whether the download completed successfully. Re-download from the official source if necessary, then recalculate the hash. If the discrepancy persists, postpone using the file and check the publisher’s announcements or documentation.

Limitations of Hashing: What It Doesn’t Prove

A matching hash isn’t proof that a program is safe. Malicious files can also have valid hashes if the distribution source or publication has been compromised. A hash only compares file contents against a reference value; it doesn’t scan for malware, encrypt files, or identify the creator on its own.

Therefore, the source of the hash value is crucial. If both the file and hash value come from the same fraudulent page, an attacker could have replaced both. For stronger assurance of origin, verify digital signatures or release signatures using trusted public keys, if the developer provides them. Always download from official sources, keep systems updated, and use appropriate security protections.

Mistakes to Avoid

  • Comparing SHA-256 against values created using a different algorithm.
  • Using a hash for a different file version.
  • Copying reference values from unclear or untrusted sources.
  • Treating a matching result as proof the file is malware-free.
  • Ignoring differing characters just because most of the hash looks similar.

Conclusion

Checking SHA-256 is a simple step to help ensure a file hasn’t changed compared to a reference value. On Windows, use Get-FileHash; on macOS, use shasum -a 256; and on Linux, use sha256sum. Always match results against trusted sources, ensure the file version is correct, and remember that integrity doesn’t equal security. For important files, combine hash verification with digital signature checks and safe downloading practices.

Bagikan artikel ini

No comments yet

    Leave a comment

    Your email address will not be published. Required fields are marked *