Skip to main content

No, you didn’t encrypt the password — a developer’s guide to hashing

Updated 4 min readMarkdown

There's a sentence I've seen in code reviews, Slack threads, and more than one incident postmortem: "Don't worry, the passwords are encrypted." Nine times out of ten, they weren't encrypted — they were hashed. The two words get used interchangeably, and that confusion is exactly how real security mistakes slip in. Let's fix the mental model, because once it clicks the right design decisions become obvious.

Encryption vs hashing in one line

Encryption is a round trip. You scramble data with a key, and with that key you unscramble it back to the original. The whole point is to get the plaintext back later.

Hashing is a one-way street. You feed in data and get a fixed-size fingerprint out. There is no key, and there is no "decrypt" — the original is not stored anywhere inside the fingerprint. SHA-256 doesn't encrypt anything; it summarizes. When someone says "I'll decrypt the hash," they're describing an operation that doesn't exist.

That single distinction — do you ever need the original back? — decides which tool you want.

What SHA-256 actually gives you

SHA-256 takes any input and produces a 256-bit fingerprint, 64 hex characters:

e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

(that's the hash of an empty string). Three properties make it useful:

  • Deterministic: the same input always produces the same fingerprint. That's what makes it verifiable.
  • One-way: you can't run it backwards to recover the input.
  • Avalanche effect: flip a single bit of the input and roughly half the output bits change. So you can't tell how similar two inputs were by comparing their hashes — "close" inputs give wildly different outputs.

Where hashing is the right tool

Integrity checks. Publish the SHA-256 of a download. Anyone who fetches the file recomputes the hash; if it matches, the bytes weren't tampered with in transit. You're not hiding the file — you're proving it's unaltered. This is also the backbone of how Git names commits and how blockchains chain blocks.

Deduplication and cache keys. Hash the content, use the fingerprint as the key. Identical content collapses to the same key for free.

Where hashing is not enough — the password trap

"Store passwords hashed" is correct advice that people then implement wrong. Raw SHA-256 on a password is a bad idea on its own, for two reasons:

  1. It's fast. That's a feature for integrity checks and a bug for passwords — an attacker with a leaked table can test billions of guesses per second against it.
  2. It's unsalted by default. Two users with the same password get the same hash, and precomputed rainbow tables walk right through it.

The real answer for passwords is a slow, salted key-derivation function: bcrypt, scrypt, or Argon2. They're deliberately expensive and salt every entry, which is exactly what you want when the whole point is to make guessing painful. SHA-256 is a fingerprint primitive, not a password-storage scheme.

And don't reach for SHA-1 or MD5

Both have demonstrated collisions — researchers can construct two different inputs with the same hash, which breaks any security guarantee built on them. SHA-256 has no known practical collisions and is the standard to default to today.

A 10-second checklist

  • Do you need the data back later? → Encryption (with real key management).
  • Do you need to prove data didn't change? → Hash (SHA-256).
  • Are you storing passwords? → bcrypt / scrypt / Argon2, never a bare fast hash.
  • Using MD5 or SHA-1 for anything security-sensitive? → Stop and migrate.

Try it yourself

The fastest way to build intuition is to watch the avalanche effect happen: hash a word, change one letter, and see the entire fingerprint change. I use a hash tool that runs entirely in the browser via the Web Crypto API — your text never leaves the device — so it's safe to paste real strings into: hash generator.

If you want the full property-by-property breakdown, including the "a hash is not encryption" table and the SHA-256 vs SHA-1 vs MD5 comparison, the long-form version is here: What is SHA-256 and what it is for.

Bottom line

Hashing and encryption solve opposite problems: one proves data is intact, the other keeps it confidential and recoverable. SHA-256 is a one-way fingerprint — great for integrity, wrong as a bare password store, and not "encryption" no matter how often the word gets reused. Get the vocabulary right and the architecture follows.

About the author

  • Developer from Chile building small, fast, client-side web tools — the kind that do one thing well and respect your data (no uploads, no signup). Creator of Toolonium. Here to share what I learn about clean UX and privacy-first tooling.

No comments yet. Be the first to comment.

More from this blog