Skip to content
T
Tools.Town
Free Online Tools for Everyone
Security

Hash Algorithms Explained — MD5, SHA-1, SHA-256 & Beyond

A plain-language guide to cryptographic hash functions. Learn what hashing is, how it works, and which algorithm to pick for passwords, file verification, or blockchain.

8 March 2026 4 min read By Tools.Town Team Fact Checked

Key Takeaways

  • A hash function takes any input (text, file, password) and produces a fixed-length string of characters called a digest
  • No — hashing is a one-way function by design
  • MD5 produces a 128-bit (32 hex character) digest
  • For file integrity checks: SHA-256

What is a Hash Function?

A cryptographic hash function transforms any piece of data — a word, a file, a full database — into a fixed-length string of characters called a digest or hash.

Think of it like a fingerprint machine: feed it a document, get a unique fingerprint back. Change a single full stop in the document, and the fingerprint changes completely.

Key property: Hashing is deterministic (same input always gives same output) and one-way (you cannot reconstruct the input from the digest).


The Four Core Properties of a Cryptographic Hash

Deterministic

Same input always produces the same digest, every time.

Pre-image Resistant

Cannot reconstruct the original input from the digest.

Avalanche Effect

Even a tiny input change produces a completely different digest.

Collision Resistant

Computationally infeasible to find two different inputs with the same digest.


The Major Hash Algorithms

MD5 (1992)

MD5 produces a 128-bit (32 hex character) digest. It was the internet’s default checksum algorithm for over a decade.

Status: ⚠️ Cryptographically broken

Researchers demonstrated practical collision attacks against MD5 in 2004. By 2008, forged SSL certificates were produced using MD5 collisions. It should never be used for security purposes today.

✅ Still acceptable for: non-security checksums, deduplication, legacy system compatibility.

Read the full MD5 guide →


SHA-1 (1995)

SHA-1 produces a 160-bit (40 hex character) digest. It replaced MD5 as the web’s default for SSL certificates and Git commit IDs.

Status: ⚠️ Cryptographically broken

Google’s SHAttered attack (2017) produced the first SHA-1 collision — two different PDF files with the same SHA-1 hash. Major browsers and CAs now reject SHA-1 certificates.

✅ Still used in: Git (being phased out), legacy systems. Git uses SHA-1 for object IDs where collision exploitability is low due to other protections.

Read the full SHA-1 guide →


SHA-256 (2001)

SHA-256 produces a 256-bit (64 hex character) digest and is part of the SHA-2 family.

Status: ✅ Secure — current standard

SHA-256 underpins TLS 1.3, Bitcoin’s proof-of-work, HTTPS certificates, and most modern security infrastructure. No practical attacks exist against it.

Read the full SHA-256 guide →


SHA-384 (2001)

SHA-384 produces a 384-bit (96 hex character) digest, also part of the SHA-2 family. It’s a truncated version of SHA-512 with different initial hash values.

Status: ✅ Secure

Used in TLS for cipher suites requiring stronger guarantees, and in some government / financial applications. Slightly slower than SHA-256 but offers a wider security margin.

Read the full SHA-384 guide →


SHA-512 (2001)

SHA-512 produces a 512-bit (128 hex character) digest — the widest of the SHA-2 family.

Status: ✅ Secure — strongest SHA-2

On 64-bit CPUs, SHA-512 can actually be faster than SHA-256 due to wider registers. Used in high-security contexts including DNSSEC, SSH key fingerprints, and digital signatures.

Read the full SHA-512 guide →


Quick Comparison Table

Algorithm Output bits Hex length Broken? Use today?
MD5 128 32 chars ✅ Yes ❌ Not for security
SHA-1 160 40 chars ✅ Yes ❌ Not for security
SHA-256 256 64 chars ❌ No ✅ Yes (standard)
SHA-384 384 96 chars ❌ No ✅ Yes (high security)
SHA-512 512 128 chars ❌ No ✅ Yes (high security)

Common Use Cases

File integrity verification. Download a file and compare its SHA-256 digest against the one published by the author. Any byte change — even a single bit flip — produces a completely different hash, making corruption and tampering immediately visible.

Password storage. Never store raw password hashes. Use an adaptive algorithm like Argon2id, bcrypt, or scrypt instead — they add a unique salt per password and apply thousands of iterations to make brute-force attacks slow regardless of hardware improvements.

Digital signatures. Hash the document first to get a fixed-size digest, then sign the digest with your private key. Recipients re-hash the document and verify the signature — this confirms both authenticity and integrity without needing to sign the full document.

Blockchain and proof of work. Bitcoin mining requires finding a nonce such that SHA-256(SHA-256(block + nonce)) starts with N leading zeros. The puzzle is computationally expensive to solve but trivially fast to verify — the asymmetry is what makes the system secure.

Data deduplication. Cloud storage providers hash every uploaded file. If two users upload the same file, the identical digest means only one copy is stored on disk — both accounts reference the same hash pointer, saving storage without exposing anyone’s data.


What Hashing Is NOT

Hashing is not encryption — you cannot decrypt a hash; encryption uses keys and is reversible. Not encoding — Base64 is reversible; hashing is not. Not suitable for secrets in transit — use TLS/HTTPS for transmission security.


Try It Yourself

echo -n "hello" | sha256sum

Use the Hash Generator to compute MD5, SHA-1, SHA-256, SHA-384, and SHA-512 digests instantly — right in your browser, with no data sent to any server.

Advertisement

Try Hash Generator — Free

Apply what you just learned with our free tool. No sign-up required.

Try Hash Generator

Frequently Asked Questions

What is a hash function?
A hash function takes any input (text, file, password) and produces a fixed-length string of characters called a digest. The same input always produces the same digest, but changing even one character in the input produces a completely different digest.
Can a hash be reversed?
No — hashing is a one-way function by design. You cannot mathematically 'unhash' a digest. Attackers use rainbow tables or brute force to guess the original input, which is why strong passwords and salting matter.
What is the difference between MD5, SHA-1, and SHA-256?
MD5 produces a 128-bit (32 hex character) digest. SHA-1 produces 160-bit (40 characters). SHA-256 produces 256-bit (64 characters). Larger output means more collision resistance. MD5 and SHA-1 are cryptographically broken for security use; SHA-256 or SHA-512 are recommended.
Which hash algorithm should I use?
For file integrity checks: SHA-256. For password storage: bcrypt, scrypt, or Argon2 (not raw SHA hashes). For digital signatures and blockchain: SHA-256 or SHA-512. Never use MD5 or SHA-1 for security-critical purposes.
What is a collision?
A collision occurs when two different inputs produce the same hash digest. Because hash functions map infinite input to finite output, collisions are mathematically inevitable, but a good algorithm makes finding them computationally impractical.

Was this guide helpful?

Your feedback helps us improve our content.

Continue Reading

All Security Guides

Get the best Security tips & guides in your inbox

Join 25,000+ users who get our weekly security insights.