Encoding, hashing and encryption are not the same thing
Three transformations that look similar (a string turns into gibberish) but promise completely different things. Mixing them up is behind many cryptographic failures. What each one guarantees and when to use it.
In one sentence
Encoding changes format and hides nothing. Hashing is one-way and proves integrity. Encryption is reversible with a key and provides confidentiality. Pick by the guarantee you need.
Same input, three outputs
Base64 output looks scrambled, which is why "encrypted with Base64" shows up in real code reviews. But anyone can decode it. A hash can't be reversed at all, and encryption can only be reversed by whoever holds the key.
YW5hQG1haWwudGVzdA==Anyone can reverse it. No key, no secret. · Format conversion: putting bytes in URLs, JSON, email
One-way. Same input → same output; tiny change → totally different output. · Integrity checks, deduplication (passwords need a slow hash, not this one)
…Reversible only with the key. Random IV: same input → different output each time. · Confidentiality: data at rest and in transit
Which one do you need?
| You need to… | Use | Not |
|---|---|---|
| Put binary data in JSON or a URL | Base64 / URL encoding | Encryption (pointless) or hashing (loses data) |
| Check a file wasn't changed | SHA-256 hash (HMAC if an attacker could change both) | MD5 / SHA-1 (broken for collisions) |
| Store passwords | Argon2id / bcrypt (slow hash) | Encryption or fast hashes |
| Keep data secret, read it later | AES-256-GCM or ChaCha20-Poly1305 via a vetted library / KMS | ECB mode, home-made crypto, keys next to the data |
| Prove who sent a message | Signatures (Ed25519, ECDSA) or HMAC | A plain hash: anyone can recompute it |
Key takeaways
- 01Encoding is not security: anyone can decode it.
- 02Hashes are one-way; passwords need a slow one.
- 03Encryption is only as safe as the key's storage.
- 04Prefer authenticated encryption from vetted libraries.
Check your understanding
1 of 3
Encoding, hashing or encryption: which one hides nothing?
Related concepts
Password storage
Never store passwords, store slow, salted hashes made with Argon2id or bcrypt. MD5 and SHA-256 are built to be fast, and fast is exactly what an attacker with GPUs wants.
7 min read →TLS
TLS gives you confidentiality, integrity and server authentication. Without validating the certificate you get encryption with whoever is in the middle.
6 min read →Secrets management
A secret in a repo is leaked, even after you delete it. Keep secrets in a vault or the platform's secret store, scan before push, scope every key, and revoke first, investigate second.
6 min read →