Skip to content
Free Tools Galaxy
Security
#️⃣

What Is a Hash? MD5 vs SHA-256 Explained

By The Free Tools Galaxy Team6/16/20265 min read

If you have ever downloaded a file and seen a long string labelled 'MD5' or 'SHA-256' next to it, you have met a hash. Hashing is one of the quiet workhorses of computing and security, used everywhere from verifying downloads to storing passwords safely. Understanding what a hash is — and what it is not — clears up a lot of confusion about how data is protected.

What a hash function does

A hash function takes any input — a word, a password, an entire file — and produces a fixed-length string of characters called a hash or digest. The same input always produces the same hash, but even a tiny change to the input produces a completely different output. Hashing the word 'hello' gives one fixed result; changing it to 'Hello' gives a totally different one, with no resemblance to the first.

Why a hash is one-way

The defining feature of a good hash function is that it is one-way: you can easily turn an input into a hash, but you cannot reverse the hash back into the original input. There is no 'unhash' operation. This is what makes hashing useful for storing passwords — a website can store the hash of your password and check it at login without ever keeping the actual password, so a database leak does not directly expose what you typed.

MD5 vs SHA-256

MD5 and SHA-256 are two well-known hash functions, and the difference matters. MD5 produces a shorter 128-bit hash and was extremely popular for years, but it is now considered broken for security purposes: researchers can deliberately create two different inputs that share the same MD5 hash, a flaw called a collision. SHA-256, part of the SHA-2 family, produces a longer 256-bit hash and has no known practical collisions, making it the modern standard for security-sensitive work.

  • MD5: fast, 128-bit output, fine for quick non-security checks like detecting accidental file changes — but not safe for passwords or security.
  • SHA-256: slightly slower, 256-bit output, no known practical collisions — the right choice for verifying authenticity and securing data.
  • For passwords specifically, even SHA-256 alone is not enough; dedicated, deliberately slow algorithms with a 'salt' are used instead.

What hashing is good for

Hashing shows up in more places than most people realise. When you download software, the site often publishes the file's SHA-256 hash so you can hash your copy and confirm the two match — proof the file arrived intact and untampered. Version-control systems identify every snapshot of code by its hash. And blockchains chain blocks together using hashes. The common thread is integrity: a hash is a compact fingerprint that changes the moment the underlying data changes, so it instantly reveals tampering or corruption.

Hashing is not encryption

This is the most important distinction to get right. Encryption is two-way — you encrypt data with a key and can decrypt it back with the right key. Hashing is one-way and has no key and no way back. So hashing is for verifying and fingerprinting data, while encryption is for keeping data secret and later recovering it. Confusing the two leads to real mistakes, like assuming a hashed value can be 'decrypted' — it cannot.

How to verify a downloaded file with a checksum

  1. Find the official hash: reputable download pages publish the file's SHA-256 checksum right next to the download link. Copy it.
  2. Hash your copy: open our SHA-256 generator, load the downloaded file, and let it compute the digest locally in your browser.
  3. Compare the two strings carefully — every character must match. Pasting both into a text-diff tool removes any squinting.
  4. If they differ, do not install the file. Re-download from the official source; a mismatch means the file is corrupted or has been tampered with.

Frequently asked questions

Can two different files ever have the same hash?

In theory, yes — there are infinitely many possible inputs and only a fixed number of possible hashes, so collisions must exist. What matters is whether anyone can find one deliberately. For MD5 they can, which is why it is retired from security work; for SHA-256 no practical method is known, which is why a matching SHA-256 is treated as proof the files are identical.

What is a salt, and why do passwords need one?

A salt is a random value added to each password before hashing, so two users with the same password end up with completely different hashes. It defeats attackers who precompute tables of common passwords and their hashes, because every salted hash has to be attacked individually.

Is SHA-512 better than SHA-256?

It produces a longer digest from the same trusted family, but for verifying files and everyday integrity checks, SHA-256 already offers more security margin than you will realistically ever need. The choice between them is usually about platform performance, not safety.

Security practices evolve, and algorithms once considered safe can become weak over time. For anything security-critical, follow current expert guidance and use up-to-date, recommended algorithms rather than older ones like MD5.

The bottom line

A hash is a one-way fingerprint of data: same input, same hash, and no way to reverse it. MD5 is fast but broken for security, while SHA-256 is the dependable modern choice. Remember that hashing verifies integrity rather than hiding secrets — that job belongs to encryption. Try it yourself with our in-browser hash generators, which compute everything locally without sending your data anywhere.