Few topics cause more confusion — and more security bugs — than the difference between hashing, encryption, and encoding. They all transform data, but they solve completely different problems, and mixing them up leads to real vulnerabilities like storing reversible “encrypted” passwords or treating Base64 as a secret. This guide draws the lines clearly. You can experiment with the underlying operations using our SHA hash generator and Base64 encode/decode tool.
The one-sentence summary
- Encoding = make data compatible with a channel. Reversible by anyone, no key.
- Encryption = make data confidential. Reversible only with a key.
- Hashing = make a fingerprint. Not reversible at all.
The fastest way to choose correctly is to ask two questions: Do I need to get the original back? and Should only certain people be able to read it?
What is encoding?
Encoding converts data from one representation to another so it can travel safely through a system that expects a particular format. There is no key and no secret — the scheme is public, and anyone can reverse it.
Common examples:
- Base64 — turns binary into text-safe ASCII (see Base64 encoding explained).
- URL/percent-encoding — makes text safe inside a URL (try the URL encode/decode tool).
- Character encodings like UTF-8 — map characters to bytes.
Encoding provides zero security. If you Base64 a password, you have not protected it; you have merely written it in a different alphabet that any decoder reverses in milliseconds.
What is encryption?
Encryption transforms readable data (plaintext) into unreadable data (ciphertext) using an algorithm and a key. Only someone with the correct key can decrypt it back. Its purpose is confidentiality.
There are two broad families:
- Symmetric (e.g. AES): the same key encrypts and decrypts. Fast; used for bulk data.
- Asymmetric (e.g. RSA, elliptic-curve): a public key encrypts, a matching private key decrypts. Used for key exchange and signatures.
Encryption is reversible by design — but only with the key. Lose the key and the data is unrecoverable; leak the key and the protection is gone.
What is hashing?
Hashing runs data through a one-way function that produces a fixed-size digest (for example, 256 bits for SHA-256). The same input always yields the same digest, but there is no way to reverse the digest back to the input. Its purposes are integrity and verification, not confidentiality.
Use cases:
- File integrity: publish a SHA-256 so downloaders can confirm a file was not corrupted or tampered with.
- Password storage: never store passwords; store a salted, slow hash (bcrypt, scrypt, Argon2) so a database breach does not reveal them.
- Deduplication and fingerprinting: identify identical content by digest.
You can compute SHA-1/256/384/512 digests of any text in the SHA hash generator. Note that plain SHA-256 is fine for integrity but not for passwords — passwords need a deliberately slow, salted algorithm to resist brute force.
Side-by-side comparison
| Encoding | Encryption | Hashing | |
|---|---|---|---|
| Goal | Compatibility / transport | Confidentiality | Integrity / verification |
| Reversible? | Yes, by anyone | Yes, with the key | No |
| Needs a key? | No | Yes | No (optional for HMAC) |
| Output size | Grows ~33% (Base64) | ~Same as input | Fixed (e.g. 256 bits) |
| Examples | Base64, URL-encoding, UTF-8 | AES, RSA | SHA-256, bcrypt, Argon2 |
| Security provided | None | Confidentiality | Tamper-evidence |
How to choose: a decision flow
- Do you need to get the original data back?
- No, you only need to verify it → hash it. (Passwords, file checksums.)
- Yes → continue.
- Should only authorized parties be able to read it?
- Yes → encrypt it. (API keys at rest, private messages.)
- No, you just need it to survive a text channel → encode it. (Binary in JSON, values in a URL.)
Common mistakes to avoid
- “We Base64 the password before sending it.” That is encoding, not protection. Use TLS for the channel and hash the password at rest.
- “We encrypt passwords in the database.” Encryption is reversible — a stolen key exposes every password. Hash passwords instead, with a slow salted algorithm.
- “Hashing hides the data.” A hash is a fingerprint, not a hiding place; identical inputs always produce identical digests, so unsalted hashes of small inputs (like phone numbers) can be brute-forced.
- “A JWT is encrypted.” A standard signed JWT is only encoded (Base64URL) and signed (a keyed hash), not encrypted — its claims are readable by anyone. See how to decode a JWT.
Sources
- IETF RFC 4648 (Base64/encoding) and RFC 8259 (JSON).
- NIST FIPS 180-4, Secure Hash Standard (SHS).
- OWASP, Password Storage Cheat Sheet (salted, slow hashing guidance).