The difference comes down to three dimensions: reversibility, keys, and output shape. Confusing them is not a quiz mistake but a real incident — passwords stored as Base64 (which is plaintext), signature checks that confuse decoding with verification, installers trusted after a single MD5 comparison.
One Table, Three Dimensions
| Dimension | Encoding | Hashing | Encryption |
|---|---|---|---|
| Purpose | Fit a channel or format | Verify integrity, fingerprint | Confidentiality |
| Reversibility | Reversible, table is public | Irreversible, information is discarded | Reversible, given the key |
| Key | None | None (password hashing adds salt) | Required and secret |
| Output shape | Text inside a charset | Fixed-length digest | Ciphertext roughly the size of plaintext |
| Same input | Deterministic | Deterministic | Deterministic modes yes; random IV differs each time |
| Examples | Base64, URL encoding, Hex | MD5, SHA-256, bcrypt | AES-GCM, ChaCha20, RSA |
In one line: encoding re-represents, hashing fingerprints, encryption locks. Locks need keys, fingerprints cannot be reversed, and anyone can re-represent.
Encoding Is Not Encryption: One Step Back
"Base64 output looks like gibberish, so it must be encrypted" is the classic mistake. The gibberish feeling comes only from a different alphabet; the table is a public standard and decoding needs no secret:
echo -n "admin:123456" | base64 # -> YWRtaW46MTIzNDU2
echo "YWRtaW46MTIzNDU2" | base64 -d # -> admin:123456 (anyone, one step)
No key participates, so no confidentiality exists. Base64's real job is transport compatibility: letting binary data cross text-only channels such as email bodies, JSON strings, or URL parameters. Details in Base64 encoding explained.
URL encoding (%E4%BD%A0) and Unicode escapes (\u4f60) belong to the same category: they answer whether a character can legally appear in a given format, nothing about secrecy. One test decides it — if decoding needs no secret, it is not encryption.
Why Hashing Is Irreversible: "Decryption Sites" Are Looking Up
SHA-256 compresses input of any length into a fixed 32-byte digest, and information is discarded along the way: only 2²⁵⁶ outputs exist while inputs are infinite, so countless inputs share one digest. There is simply not enough information in a digest to rebuild the original. It is not that the algorithm hides something; the information is gone.
That is why "MD5 decryption" sites do not reverse anything. They look up: precompute hashes of massive candidate lists, match yours, and return the hit. That is the whole risk of bare-hash password storage — an attacker needs a large table, not an understanding of SHA-256.
The correct posture for passwords is salt plus a slow hash: a salt makes the same password produce different digests per user, breaking bulk rainbow-table lookups, and slowness raises each guess from nanoseconds to tens of milliseconds. Algorithms and parameters in the password hashing guide.
The Core of Encryption Is the Key
The AES and ChaCha20 specifications are public, and confidentiality rests entirely on the key. Three engineering consequences follow:
- Key management fails more often than algorithm choice: keys hardcoded in source or committed in config files cause more incidents than a misused ECB mode.
- Public algorithms are not a weakness: Kerckhoffs' principle says everything except the key may be public and the system should still hold.
- Mode choice matters just as much: AES-ECB emits identical ciphertext blocks for identical plaintext blocks (the ECB penguin), while AES-256-GCM provides confidentiality and an integrity check together. Mode comparison in AES encryption modes.
Five Scenarios, Five Tools
| Task | Correct tool | Do not use |
|---|---|---|
| Store login passwords | bcrypt / argon2 (salted slow hash) | |
| Verify a download was not altered | SHA-256 against the publisher's digest | |
| Push binary through a text channel | Base64 / Base64URL | |
| Sensitive database fields | AES-GCM or another authenticated cipher | |
| Tamper-proof API payloads | HMAC-SHA256, a keyed hash |
The fourth row is the one people invert: irreversibility means data "stored" as a hash can never be read back. Hashing a phone number for later display is impossible by design, and storing it as Base64 is plaintext with extra steps. This case needs encryption, not encoding or hashing.
Same Input, Three Outputs
import base64, hashlib
msg = b'hello world'
print(base64.b64encode(msg).decode()) # aGVsbG8gd29ybGQ= <- encoding: reversible, keyless
print(base64.b64decode(base64.b64encode(msg))) # b'hello world' <- one step back
print(hashlib.sha256(msg).hexdigest()) # b94d27b9934d3e08… <- hashing: one-way
print(len(hashlib.sha256(msg).digest())) # 32 (256 bit, independent of input length)
Then run AES-CBC through OpenSSL with an explicit key and IV so the result is reproducible:
echo -n "hello world" | openssl enc -aes-128-cbc \
-K 000102030405060708090a0b0c0d0e0f \
-iv f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff | xxd -p
# -> ciphertext; change -K to any other 16 bytes and the output changes completely
Those three shapes are the boundary: encoding changed the representation, hashing discarded information, encryption locked the data. To check it yourself, the AES encrypt/decrypt, text hash, and Base64 converter tools run locally in the browser and upload nothing.