← Lessons

quiz vs the machine

Gold1320

Security

Hashing versus Encryption

Why a hash is one way and how that differs from reversible encryption.

4 min read · core · beat Gold to climb

Two Different Tools

People often confuse hashing and encryption, but they serve different goals.

Encryption is reversible. With the correct key you can recover the original plaintext. It protects confidentiality, keeping data readable only to key holders.

Hashing is one way. A cryptographic hash like SHA two hundred fifty six maps any input to a fixed size digest, and there is no key and no way to reverse it back to the input. It protects integrity and lets you compare values without storing them.

Choosing Correctly

  • Use encryption when you must read the data again later, such as stored card numbers.
  • Use hashing when you only need to verify a value, such as confirming a download or comparing passwords.
  • Never store passwords with reversible encryption when a one way slow hash is the correct tool.

A good cryptographic hash is collision resistant, meaning it is impractical to find two inputs with the same digest.

Key idea

Encryption is reversible with a key for confidentiality, while hashing is a one way digest for integrity and verification, so choose the tool that matches whether you need to read the data again.

Check yourself

Answer to earn rating on the learn ladder.

1. What is the key difference between hashing and encryption?

2. Which task is best served by hashing?