Skip to content
LeedyBox
Support

Hash Functions Explained

A hash function turns any input into a short, fixed-length fingerprint. This guide explains what MD5, SHA-1 and SHA-256 are useful for, where they fall short, and how to compare a file with a published checksum.

What a Hash Is

A cryptographic hash function reads data of any size and produces a digest of fixed length: 128 bits for MD5, 160 bits for SHA-1 and 256 bits for SHA-256, usually shown as hexadecimal text. The same input gives the same digest every time, and changing even one bit of the input produces a very different digest. A hash is one-way: you cannot recover the input from the digest, except by guessing inputs and comparing the results.

This guide gives general information. For security decisions, follow the requirements of your organisation or the service you are working with.

Checksums and Integrity

The most common everyday use is checking that a file arrived intact. A download page may publish a SHA-256 value next to the file. After downloading, you calculate the hash of your copy and compare it with the published one. If the values match, the file is very likely identical to the one the publisher hashed; if they differ, the download is corrupted or the file is a different version.

A checksum only helps if the published value itself can be trusted. If an attacker can change both the file and the checksum on the same page, a matching hash proves little. Digital signatures address that problem.

Why MD5 and SHA-1 Are Not for Security

A secure hash should make it impractical to find two different inputs with the same digest (a collision). Practical collision attacks have been published for both MD5 and SHA-1, so an attacker can prepare two different files that share a hash. For this reason, they are no longer considered suitable for digital signatures, certificates or other security uses.

MD5 and SHA-1 can still detect accidental corruption, and some older systems publish them. For new work, SHA-256 or another member of the SHA-2 family (SHA-384, SHA-512) is the usual choice.

Algorithm Digest length Security status
MD5 128 bits (32 hex characters) Broken for collisions; legacy checksums only
SHA-1 160 bits (40 hex characters) Broken for collisions; legacy use
SHA-256 256 bits (64 hex characters) Widely used and recommended
SHA-384 / SHA-512 384 / 512 bits Widely used and recommended

Hashing Is Not Encryption, and Passwords Need More

Encryption is reversible with the right key; hashing is not designed to be reversed. A hash does not hide short or predictable inputs, though: anyone can hash common words or phone numbers and look for a match.

That is why fast hashes such as MD5 or SHA-256 alone are not suitable for storing passwords. They are designed to be fast, which lets an attacker test a very large number of guesses quickly. Password storage uses slow, salted algorithms built for the purpose, such as Argon2, scrypt or bcrypt. If you build a login system, use a maintained library and the current guidance for your platform rather than a general-purpose hash.

HMAC for Message Authentication

A plain hash shows whether data changed, but anyone can recompute it. HMAC (hash-based message authentication code) combines the data with a secret key, for example HMAC-SHA256. Only someone who knows the key can produce the correct value, so the receiver can check that a message came from a key holder and was not altered. Webhooks and API request signing commonly use HMAC. Keep the key secret; anyone who has it can create valid codes.

Why the Same Text Gives a Different Hash

A hash is calculated over bytes, not over the text you see. These differences change the result:

  • Line endings: Windows uses CR LF, while Linux and macOS use LF.
  • Character encoding: "é" is different bytes in UTF-8 and in older encodings.
  • A trailing newline or space, or a byte order mark at the start of a file.
  • Upper vs lower case in the input.

When a hash does not match, check these first. Hashing the original file is usually more reliable than hashing text copied from it. The hex output itself is not case-sensitive: A1B2 and a1b2 are the same value.

Frequently Asked Questions

Can I decrypt an MD5 or SHA-256 hash?

No. A hash is not encrypted data. Online "decrypt" services look up precomputed hashes of common inputs, which is why hashes of simple values offer little protection.

Which algorithm should I use to verify a download?

Use the one the publisher provides. If several are offered, SHA-256 or SHA-512 is the better choice than MD5 or SHA-1.

Does the Hash Generator upload my file?

The LeedyBox Hash Generator calculates hashes in your browser, so the text or file you select is processed on your device.