Few topics cause as much confusion as the difference between hashing, encryption and encoding. They are used in different situations for different reasons, and mixing them up leads to real security mistakes — like treating Base64 as if it protected data. Here is the clear version.
Encoding: for safe transport
Encoding transforms data into a different format so it can travel safely through a channel. Base64 and URL-encoding are the common examples. Encoding provides no security whatsoever — it is fully reversible by anyone, and that is the point. Use it to make binary data text-safe or to put special characters in a URL, never to hide anything.
Hashing: one-way fingerprints
Hashing turns input of any size into a fixed-length fingerprint that cannot be reversed. The same input always produces the same hash, and a tiny change produces a completely different one. Hashing verifies integrity (has this file changed?) and, with salting, stores passwords without keeping the originals. You cannot get the input back from a hash — that one-way property is its value.
Encryption: reversible with a key
Encryption scrambles data so it is unreadable without a key, and reverses with the right key. Unlike hashing, it is meant to be undone — by authorised parties. Use it to protect data that needs to be read again later: a message, a file, a stored secret. The security rests entirely on key management.
The rule of thumb
- Need to read it back, anyone allowed? Encoding.
- Need to read it back, only with a key? Encryption.
- Never need it back, just to verify? Hashing.