Encoding changes the format, encryption hides data behind a key, and hashing is one-way.
Encoding changes how data is represented, for transport or storage. Examples are base64, URL encoding and UTF-8. It uses no key, and anyone can reverse it. So it gives no security. For example, a JWT payload is base64url-encoded, and anyone can read it.
Encryption transforms data with a key. Only people with the key can reverse it. Use it when you need the original data back. Examples are third-party API credentials, or sensitive fields like national ids. Use AES-256-GCM or a KMS (Key Management Service, a cloud service that stores and uses keys for you).
Hashing is one-way. It turns any input into a fixed-size value called a digest, and you can't reverse it. Use it for integrity checks. Also use it for passwords, with slow, salted algorithms like Argon2id. A salt is a random value added to each password before hashing. For passwords, you only ever check them. You never need the original back.
The classic trap: passwords are hashed, not encrypted.
- Encoding is reversible, uses no key and gives no security.
- Encryption is reversible with a key, for data you need back.
- Hashing makes a one-way digest, for integrity checks and passwords.
- Passwords are hashed with slow, salted functions.
- Cryptographic Storage Cheat Sheet (OWASP) (https://cheatsheetseries.owasp.org/cheatsheets/Cryptographic_Storage_Cheat_Sheet.html)cheatsheetseries.owasp.org
- Password Storage Cheat Sheet (OWASP) (https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html)cheatsheetseries.owasp.org