Skip to content

7 min read

American Corners

Encryption vs hashing

Two tools that look alike

Encryption and hashing both turn readable data into something unreadable, so people often assume they are the same trick. They are not. The key difference is simple: encryption can be reversed with the right key, and hashing cannot be reversed at all, by design. Once you see that, it is clear why each is used for a different job.

Encryption: locked, but openable

Encryption scrambles data so that only someone with the right key can turn it back into the original. Lock it with the key, unlock it with the key. The aim is to keep data private while still letting the right person read it later.

You rely on this constantly, usually without noticing. The padlock icon in your browser means the connection is encrypted, so what you send, a password, a card number, travels scrambled and cannot be read by someone watching the network. Messaging apps that offer "end to end encryption" do the same for your chats. The whole value is that the process is reversible for the intended reader, and unreadable for everyone else.

Hashing: a one-way fingerprint

Hashing runs data through a fixed calculation and produces a short string, a "hash", that acts like a fingerprint of the input. The same input always gives the same hash, but you cannot work backwards from the hash to the original. There is no key that unlocks it, because it was never meant to be unlocked.

This is exactly what you want for checking things without storing the sensitive original. A well run service does not store your actual password. It stores a hash of it. When you log in, it hashes what you typed and compares the two fingerprints. If they match, you are in, and the service never had to keep your real password lying around. Hashes also check integrity: if even one character of a file changes, its hash changes completely, which flags that something was altered.

Tip

An easy way to keep them straight: encryption is a locked box (open it again with the key), while hashing is a fingerprint (it identifies something, but you cannot rebuild the person from it). If the plan is to read the data back, that is encryption; if the plan is only to check or compare, that is hashing.

Different jobs, not competitors

Because they do different things, real systems use both, often together.

  • Keeping a message private in transit so only the receiver reads it: encryption.
  • Storing passwords so they can be checked but never read back: hashing.
  • Protecting the files on a stolen laptop from being read: encryption.

Asking "which is better?" is like asking whether a lock is better than a signature. They answer different questions. Encryption keeps secrets you need to reveal again; hashing proves something matches without ever revealing it.

Try this now

Find the padlock in your browser bar and confirm a site is https. That is encryption you can see.

Where this lesson comes from

Built from

  • Workshop 1: Cybersecurity Essentials (participant guide V3.0): encryption and hashing

alphaPlan courses are built from taught programmes rather than invented for the web. Where a claim rests on an outside standard or a reported case, it is named above so you can check it rather than take our word for it.

shënim: ky material u krijua në kuadër të projektit 'U.S. Cybersecurity Leadership in AI for Albania', financuar nga departamenti i shtetit i shteteve të bashkuara. mendimet, gjetjet dhe përfundimet e paraqitura këtu janë të autorit(ëve) dhe nuk pasqyrojnë domosdoshmërisht ato të departamentit të shtetit të shteteve të bashkuara.

Disclaimer: This material was created on behalf of the 'U.S. Cybersecurity Leadership in AI for Albania' project, funded by the United States Department of State. The opinions, findings, and conclusions stated herein are those of the author(s) and do not necessarily reflect those of the United States Department of State.

Disclaimer

Found something unclear, outdated or improvable? Suggest an improvement