Security and developer tools8 min read

Cryptographic Hashes Explained: SHA-256, MD5, and Checksum Verification

A cryptographic hash turns data of any size into a fixed-length digest. Hashes are useful for detecting changes and checking downloaded files, but the right algorithm and a trustworthy source both matter.

In brief

Use SHA-256 or another current, approved hash for general integrity checks. MD5 and SHA-1 should not be selected for new collision-resistant security designs. A matching checksum confirms equality with the checked digest, not who published the file.

How hashes work

A cryptographic hash function maps an input—such as a document, archive, or message—to a fixed-length output called a digest or hash. The same bytes processed with the same algorithm produce the same digest. Changing even a small portion of the data should produce a different-looking digest, but a hash is not a reversible encryption method.

Hash functions are used for integrity checks, digital signatures, message authentication designs, and many other security protocols. The requirements differ by use case. For a simple file check, collision resistance and a trusted published checksum matter; password storage needs a dedicated password-hashing design rather than a fast general-purpose hash.

SHA-256 vs. SHA-512 vs. SHA-1 vs. MD5

High-level guidance for common hash algorithms
AlgorithmDigest lengthPractical guidanceImportant caveat
SHA-256256 bitsCommon choice for integrity checks and modern systems where SHA-256 is specifiedUse the protocol’s approved construction and parameters
SHA-512512 bitsPart of the SHA-2 family; useful when a system specifies this digestA longer digest is not automatically the right choice for every protocol
SHA-1160 bitsMay appear in legacy systems and existing identifiersDo not choose it for new uses that require collision resistance
MD5128 bitsMay appear in legacy non-security checks or old file manifestsNot suitable for security-sensitive collision-resistant integrity designs

Use the algorithm expected by the official publisher or the protocol. If a software vendor publishes a SHA-256 checksum, compute SHA-256 locally and compare that digest; computing MD5 instead does not verify the published SHA-256 value.

Verify a downloaded file

  1. Download the file from the publisher’s official site or another source you trust.
  2. Find the checksum published by that same source through a trustworthy channel. Make sure it refers to the exact file and version you downloaded.
  3. Use a hash tool to compute the digest of your local file. The Hash Generator supports common text and file hash workflows.
  4. Compare the complete digest with the publisher’s value, character by character. A single changed character means the values do not match.
  5. If they differ, do not use the file as though it passed verification. Check for a partial download, wrong version, or file corruption, and obtain a clean copy from the official source.
Integrity is not the same as authenticity. A hash match tells you that the file matches the digest you checked. It does not prove who created the file unless the checksum itself came from a trustworthy source or is authenticated using a valid signature or other trusted mechanism.

For reproducible checks, note the algorithm, exact filename, version, and source of the expected digest. Do not compare a SHA-256 value with an MD5 value or use a checksum listed for a different build.

Security limits and password storage

  • A hash is not encryption. Hashing is designed to be one-way; there is no decryption key that restores the original file from the digest.
  • Collisions are possible in principle. A collision occurs when different inputs produce the same digest. Security depends on the algorithm’s properties and the relevant attack model.
  • A checksum alone does not authenticate a publisher. If an attacker can replace both the file and the checksum, the pair can still match. Use verified signatures or a trusted distribution channel when authenticity matters.
  • Do not store passwords using a plain fast hash. Use a dedicated password-hashing algorithm such as Argon2id, scrypt, bcrypt, or an appropriately configured PBKDF2 implementation, with a unique salt and suitable work factors.
  • Use HMAC or digital signatures for the right problem. A plain hash does not provide message authentication by itself. Follow the security protocol’s documented construction rather than inventing one.

For production security systems, follow current standards and vetted libraries. A utility page can help inspect a digest, but it cannot decide whether a particular cryptographic construction is appropriate for your application.

Frequently asked questions

Is SHA-256 better than MD5?

For modern security-sensitive collision-resistant integrity checks, SHA-256 is generally the appropriate choice when supported by the protocol. MD5 is not suitable for new security designs that rely on collision resistance.

Can a hash prove that a file came from a specific publisher?

Not by itself. A digest proves equality with the digest you checked. To establish authenticity, obtain the checksum through a trusted channel or validate an appropriate digital signature.

Can I use SHA-256 to store user passwords?

Do not use a plain fast hash for password storage. Use a purpose-built password-hashing function such as Argon2id, scrypt, bcrypt, or PBKDF2 with a unique salt and appropriate parameters.

What should I do if my checksum does not match?

Do not treat the file as verified. Check that you used the correct algorithm and version, then download the file again from the official source. If the mismatch persists, report it to the publisher.

References and related tools

Use these resources to continue checking the details or to complete the task described in this guide.

This guide is intended for practical learning and should be checked against the requirements of your own workflow. To suggest a correction, visit our Contact page or review our Editorial Policy.