Free — no signup required

Encryption vs. Hashing: The Crucial Difference

2 min read

Before diving deeper, we must clearly distinguish between two fundamental cryptographic operations that are frequently confused — even by experienced engineers. Mixing them up in a system design interview is a red flag.

Encryption is Reversible

Encryption is the process of transforming plaintext (readable data, like "Hello World") into ciphertext (scrambled output, like XyZ#9@pLq) using a mathematical algorithm and a key.

Crucially, encryption is designed to be reversed. If you possess the correct key, you can decrypt the ciphertext back into the original plaintext. It's a two-way street — the whole point is that the authorized recipient can recover the original message.

  • Use Case: Storing sensitive files on disk, sending private messages, protecting data in transit over HTTPS, encrypting database columns containing PII (Personally Identifiable Information).

Hashing is One-Way

Hashing is a mathematical function that takes data of any size and produces a fixed-size string of characters called a hash, digest, or checksum.

Crucially, hashing is a one-way operation. You cannot take a hash and reverse it to recover the original input. Think of it like running a document through a paper shredder — you can verify that two shredded piles came from the same document (by comparing the shred patterns), but you cannot reconstruct the original document from the shreds alone.

  • Use Case: Verifying that a downloaded file wasn't corrupted or tampered with, securely storing passwords in a database, generating unique identifiers for data blocks.

The Critical Distinction in Practice

A common and dangerous mistake is storing passwords using encryption instead of hashing. If passwords are encrypted, anyone who obtains the encryption key can decrypt and read every user's password. Passwords should be hashed (with salt and pepper, as covered later) — even the system administrators should not be able to recover a user's original password. If a user forgets their password, the correct response is to issue a reset, not to look up the original.

This is one of 18 chapters

Every chapter is free — Kubernetes, Terraform, SRE, distributed systems, and more — with fast daily review built in.

Sign up free