Encoding changes data into another format that anyone can reverse, encryption scrambles data so only someone with the right key can read it, and hashing turns data into a fixed-length fingerprint that is designed not to be reversed.
These three ideas sit under the wider topic of encryption and data protection, covered in Encryption for Beginners. This page focuses on one narrow question that trips up newcomers and experienced developers alike: which of the three gives you protection, and when? It is written for students, career changers, new developers and managers with no background in cryptography.
By the end of this guide you will be able to:
- Explain the difference between encoding, encryption and hashing.
- Identify why Base64 is not a way to protect a password or key.
- Describe how passwords should be stored, and why.
Key takeaways
- Encoding is not protection. Base64 and similar encodings are reversible by anyone, with no key. They exist to move data safely through systems, not to hide it.
- Encryption needs a key. It protects confidentiality, but only as well as the key is protected. Lose the key and you lose the protection.
- Hashing is one-way. It is used to check that data has not changed and to store passwords, where you never need the original back.
- Passwords need a special kind of hash. Use a slow, salted password hashing scheme such as Argon2id, not plain encoding, encryption or a fast general-purpose hash.
What it is, in plain English
Encoding means rewriting data in a different alphabet so it can travel through a system that only accepts certain characters. Base64 is the best-known example: it turns any data into a string of letters, digits and a few symbols, using 64 characters that each carry 6 bits of data.[1] The standard that defines it, RFC 4648, says Base64 can visually hide information such as passwords "but does not provide any computational confidentiality".[1] In plain terms, it looks scrambled but is not.
Encryption turns readable data, called plaintext, into unreadable ciphertext using an algorithm and a secret key. Only someone with the right key can turn it back. A widely used example is the Advanced Encryption Standard (AES), published by the US National Institute of Standards and Technology (NIST), which comes in three versions with 128, 192 or 256-bit keys.[6]
Hashing runs data through a hash function that always produces a fixed-length output, called a hash or digest. NIST describes a hash algorithm as one that maps a message of any length to a fixed-length message digest, and says a good one makes it computationally infeasible to find two inputs with the same output, or an input that matches a given output.[5] There is no key and no "unhash" button.
An everyday comparison: encoding is like writing a message in Morse code. Anyone with the chart can read it. Encryption is like putting the message in a locked box: only the key holder can open it. Hashing is like taking a fingerprint: you can check whether a person matches it, but you cannot rebuild the person from the print. Where the analogy breaks down: people can guess common passwords and compare their hashes, so a weak password can still be found from its hash, which is why password hashing adds salt and deliberate slowness.
This matters because mixing them up leads to real weaknesses. MITRE's Common Weakness Enumeration lists "Weak Encoding for Password" as CWE-261, and notes that hiding a password with an encoding such as Base64 does not adequately protect it.[2]
How it works, step by step
A simple way to choose between the three is to ask what you need to do with the data later.
- Do you just need the data to survive the journey? For example, putting an image inside an email or a web page. Use encoding. Treat the result as public, because anyone can decode it.
- Do you need to read the original again, but keep it secret from others? For example, a stored customer file or an API key your application must send to another service. Use encryption, and store the key separately, ideally in a secrets manager or key management service.
- Do you only need to check that something matches, or has not changed? For example, confirming a downloaded file is intact. Use a cryptographic hash such as SHA-256 from the SHA-2 family.[5]
- Is it a password that people type to sign in? Use a password hashing scheme. When the person signs in, the system hashes what they typed with the same salt and settings and compares the results. It never needs the original password back.
Password hashing deserves its own note, because it is where the three ideas most often get confused.
| Ingredient | What it does |
|---|---|
| One-way hash | The OWASP Password Storage Cheat Sheet explains that hashing is one-way, so a stolen hash cannot simply be reversed, while encryption is two-way and suits only rare cases where the original password must be recovered.[3] |
| Salt | A unique random value added to each password before hashing, so identical passwords give different hashes and precomputed lookup tables stop working. NIST requires salts of at least 32 bits.[4] |
| Cost factor | Deliberate slowness, so each guess costs an attacker real time. NIST says it should be as high as practical without hurting performance.[4] |
| Algorithm | OWASP lists Argon2id first, then scrypt, with bcrypt for legacy systems and PBKDF2 where FIPS 140 compliance is required.[3] |
A worked example
Brightwell Tutors is a fictional online tutoring company with a small development team. A new developer, Tom, reviews the code before a customer audit and finds two things.
First, the configuration file contains a line called payment_api_key holding a long string of letters ending in "=". A colleague says it is "encrypted". Tom recognises Base64 padding, decodes it in a few seconds and sees the live API key. The file is also in the team's shared code repository. The team treats the key as exposed: they create a new key with the payment provider, move it into the cloud provider's secrets manager, and revoke the old one. An API key like this is the credential of a non-human identity, so a leaked key is effectively a stolen identity for that service.
Second, customer passwords are stored as plain SHA-256 hashes with no salt. That is better than storing them readable, but fast and unsalted, so two customers with the same password have the same hash and common passwords are quick to guess. The team switches to Argon2id with a unique salt per user. Because they cannot reverse the old hashes, they upgrade each password the next time that customer signs in, and plan a forced reset later for accounts that do not sign in.
The changes did not make Brightwell immune to attack. They removed a key that anyone with repository access could read, and made stolen password data much slower to crack.
Common mistakes
| Mistake | What to do instead |
|---|---|
| Calling Base64 "encrypted" and storing passwords or keys that way. | Treat encoded secrets as readable. Keep secrets in a secrets manager or encrypt them with a key stored elsewhere. |
| Encrypting user passwords so they can be "recovered". | Hash them with a password hashing scheme. Offer a reset, not a recovery. |
| Using a fast general-purpose hash (MD5, SHA-1 or plain SHA-256) for passwords. | Use Argon2id, scrypt, bcrypt or PBKDF2 with a salt and a suitable cost factor. |
| Using SHA-1 for new integrity checks or signatures. | Use SHA-2 or SHA-3. NIST deprecated SHA-1 in 2011 and is transitioning away from its remaining uses.[5] |
| Storing the encryption key next to the encrypted data. | Keep keys in a separate key management service or vault with its own access controls. |
Key terms
- Encoding
- A reversible way of changing data into another representation, often to make it easier to move or store. It is not a protection mechanism.
- Base64 encoding
- A reversible way to represent binary or text data as printable characters; anyone can decode it.
- Encryption
- Converting readable data into ciphertext so it cannot be understood without the correct key.
- Ciphertext
- The unreadable output produced when plaintext is encrypted.
- Hashing
- A one-way process that converts input into a fixed-length digest, used to check integrity and to store passwords.
- Password hashing
- Converting a password into a fixed-length cryptographic value before storage, using a slow, salted scheme, so a stolen database is harder to crack.
- Salt
- A unique random value added to a password before hashing so the same password produces a different hash for each account.
First steps
Three things you can do this week:
- Search for encoded secrets. Look through configuration files and code for long strings ending in "=" or labelled as keys, tokens or passwords, and check whether they decode to something sensitive.
- Ask how passwords are stored in each system your team builds or buys. The answer should name a password hashing scheme and a salt.
- Move one exposed secret. Replace it with a new value held in a secrets manager, then revoke the old one.
Checklist
Checklist:
- No password, API key or token is stored only as Base64 or another encoding.
- Passwords are stored with Argon2id, scrypt, bcrypt or PBKDF2, with a unique salt each.
- No system can email a user their existing password.
- Encryption keys are stored separately from the data they protect.
- New integrity checks use SHA-2 or SHA-3, not MD5 or SHA-1.
- Developers know that "looks scrambled" is not the same as "encrypted".
Suggested learning pathway
- Start with the umbrella topic in Encryption for Beginners.
- For encryption on the move, read TLS and HTTPS for Beginners.
- For the wider picture of protecting information, read Data Security for Beginners.
- For why keys and tokens are identities, read Non-Human Identities for Beginners.
- For the practitioner detail, see Encoding, Encryption and Hashing.
- For how defenders test password hash strength, see the Hashcat and Password Cracking for Defenders Guide.
Standards and references
- RFC 4648: The Base16, Base32, and Base64 Data Encodings. S. Josefsson, IETF, October 2006 (Proposed Standard). https://www.rfc-editor.org/rfc/rfc4648.
- CWE-261: Weak Encoding for Password. MITRE Common Weakness Enumeration. https://cwe.mitre.org/data/definitions/261.html, accessed 27 Nov 2026.
- Password Storage Cheat Sheet. OWASP Cheat Sheet Series, OWASP Foundation. https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html, accessed 27 Nov 2026.
- SP 800-63B-4, Digital Identity Guidelines: Authentication and Authenticator Management, section 3.1.1.2 Password Verifiers. National Institute of Standards and Technology (NIST). https://pages.nist.gov/800-63-4/sp800-63b.html, accessed 27 Nov 2026.
- Hash Functions project. NIST Computer Security Resource Center. https://csrc.nist.gov/projects/hash-functions, accessed 27 Nov 2026.
- FIPS 197, Advanced Encryption Standard (AES). NIST, November 2001, updated May 2023. https://csrc.nist.gov/pubs/fips/197/final.
Related NHI Mgmt Group resources: Encoding, Encryption and Hashing · Breached password checks · API Key Management Guide