Security Playbook
16 · Crypto for developersOWASP A04:20256 min read

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.

Encoding vs hashing vs encryption (real, computed in your browser)
Encoding
Base64
YW5hQG1haWwudGVzdA==

Anyone can reverse it. No key, no secret. · Format conversion: putting bytes in URLs, JSON, email

Hashing
SHA-256

One-way. Same input → same output; tiny change → totally different output. · Integrity checks, deduplication (passwords need a slow hash, not this one)

Encryption
AES-256-GCM
…

Reversible only with the key. Random IV: same input → different output each time. · Confidentiality: data at rest and in transit

"We encrypted the passwords with Base64" is a real-world mistake. Encoding hides nothing, hashing can't be undone, and encryption is only as safe as where you keep the key.
Real SHA-256 and AES-256-GCM via the Web Crypto API. The AES key is generated in your browser and never leaves it.

Which one do you need?

You need to…UseNot
Put binary data in JSON or a URLBase64 / URL encodingEncryption (pointless) or hashing (loses data)
Check a file wasn't changedSHA-256 hash (HMAC if an attacker could change both)MD5 / SHA-1 (broken for collisions)
Store passwordsArgon2id / bcrypt (slow hash)Encryption or fast hashes
Keep data secret, read it laterAES-256-GCM or ChaCha20-Poly1305 via a vetted library / KMSECB mode, home-made crypto, keys next to the data
Prove who sent a messageSignatures (Ed25519, ECDSA) or HMACA 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