What Is a Hash and Why Do Developers Use MD5, SHA-256, and SHA-512?

javascript dev.to

You've Seen Hashes Before — You Just Didn't Know It

If you've ever downloaded software and seen something like this on the download page:

SHA-256: 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
Enter fullscreen mode Exit fullscreen mode

That's a hash. A fingerprint of the file. If your download produces a different hash, the file was corrupted — or tampered with.

Hashes are everywhere. They protect your passwords. They power blockchain. They verify software downloads. They keep API requests secure.

And yet most people who encounter them have no idea what they are or how to use them.

What Is a Hash, Actually?

A hash function takes any input — a word, a sentence, an entire file — and produces a fixed-length string of characters.

Three things make hashes useful:

Same input always produces the same output.

Hash the word "hello" with SHA-256 today and tomorrow, and you always get the exact same result. This makes hashes reliable for verification.

Even a tiny change produces a completely different hash.

Change "hello" to "Hello" (capital H) and the hash is entirely different. There's no gradual change — it's like a completely new fingerprint.

You can't reverse it.

Given a hash, there's no mathematical way to recover the original input. This is by design — it's what makes hashes safe for storing passwords.

How to Generate a Hash Right Now

You can generate hashes directly in your browser — no software to install, no account needed.

Go to the Hash Generator — type or paste any text and the hash appears instantly. You can also upload a file and hash its entire contents. Everything runs locally in your browser — nothing gets sent to a server.

The 5 Algorithms Explained in Plain English

MD5 — The Fast but Broken One

MD5 produces a 32-character hash. It's fast and widely recognized, but it's been cryptographically broken since the early 2000s. Researchers can generate two different files that produce the same MD5 hash — which defeats the purpose of a fingerprint.

When to use it: File deduplication, cache keys, non-security checksums where speed matters more than security.

When NOT to use it: Passwords, security verification, anything where trust matters.

SHA-1 — The Old Standard

SHA-1 produces a 40-character hash. It was the dominant standard for over a decade and is still used by Git for commit IDs. But like MD5, collision attacks have been demonstrated (Google's SHAttered attack in 2017).

When to use it: Legacy systems that require it. Avoid for new projects.

SHA-256 — The One You Should Use

SHA-256 produces a 64-character hash. It's the current gold standard — used in Bitcoin, TLS certificates, JWT tokens, and most modern security protocols. No practical attacks exist.

When to use it: Almost everything. This is your default choice.

SHA-384 — The Middle Ground

SHA-384 produces a 96-character hash. Part of the same SHA-2 family as SHA-256, with a larger output size. Used primarily in enterprise certificate infrastructure and government compliance contexts.

When to use it: When specific compliance standards require it.

SHA-512 — Maximum Security

SHA-512 produces a 128-character hash. The strongest option — maximum output size, maximum security margin. Slightly slower to compute but negligible for most use cases.

When to use it: Sensitive applications, maximum security requirements, or when you want maximum safety margin.

Real-World Uses You Might Not Have Considered

Verifying file downloads

You download a large installer from the internet. The website shows a SHA-256 checksum. Hash the file you downloaded and compare. If they match, the file is exactly what the publisher shipped. If not, something went wrong during download — or worse, the file was modified.

Checking if a file has changed

You have a configuration file or document that should never change without your knowledge. Hash it. Save the hash. Check it periodically. A different hash means the file changed.

Comparing files without opening them

Need to check if two large files are identical? Hash them both. Matching hashes means identical files, regardless of filename or location. Faster than comparing byte-by-byte.

Understanding password storage

When you create an account somewhere, your password should never be stored as plain text. Instead, the service hashes it and stores the hash. When you log in, they hash what you typed and compare it to the stored hash. They never store your actual password.

(Modern password storage also adds "salt" — a random value mixed in before hashing — to prevent pre-computed attacks. But the core concept is hashing.)

API request verification

Many APIs use hashed signatures to verify requests. The sender hashes the request body with a secret key and includes the hash. The receiver does the same calculation and checks if the hashes match. If they do, the request is legitimate and unmodified.

MD5 vs SHA-256 — The Quick Decision Guide

If you're not sure which to use:

  • Need it for security? → SHA-256
  • Just checking if a file downloaded correctly? → SHA-256 (or MD5 if the site only provides MD5)
  • Working with an old system that requires MD5? → MD5, with awareness of its limitations
  • Building something new? → SHA-256 as your default
  • Maximum security requirement? → SHA-512

When in doubt: SHA-256. It's secure, fast, widely supported, and universally understood.

Try the Hash Generator

Open the Hash Generator and:

  1. Type any text to see it hashed instantly
  2. Switch between MD5, SHA-1, SHA-256, SHA-384, and SHA-512
  3. Upload a file to hash its entire contents
  4. Toggle uppercase/lowercase output
  5. Copy the hash with one click

No signup. No upload to any server. Your data stays in your browser.


Other Free Developer Tools

If you found the hash generator useful, these might also come in handy:

All browser-based. All free. All private.

Read Full Tutorial open_in_new
arrow_back Back to Tutorials