Base64 is an encoding, not encryption
A Base64 string looks like noise, which is why it is so often mistaken for something secure. It is not. Base64 changes how bytes are written down; encryption changes who is able to read them. There is no key involved in Base64, so anyone who receives the string can turn it back into the original bytes in a line of code.
What Base64 actually does
It maps every 3 bytes of input onto 4 characters taken from a 64-symbol alphabet, which makes the output about a third longer. The point is not secrecy — it is making binary data survive channels that only accept text: email bodies, JSON strings, URLs, HTTP headers.
hello -> aGVsbG8= alice:secret -> YWxpY2U6c2VjcmV0 bytes FB FF -> +/8=
Decoding is a lookup in the other direction. Nothing is hidden, and nothing has to be guessed.
Where it is used, and why
- Email attachments — MIME encodes binary parts as Base64 so they can travel through a text-only transport (RFC 2045).
-
data:URIs — inline images and fonts in CSS. - JWTs — the header and payload are Base64URL-encoded JSON (RFC 7519). The signature is what protects them; the payload is readable by design.
-
HTTP Basic authentication — the credentials are sent as
Base64 of
user:password(RFC 7617).
The Basic auth example is the trap
Basic auth sends YWxpY2U6c2VjcmV0 for the username
alice and password secret. That string is not
encrypted. It has to be sent over TLS, because anyone who can read the header
can decode the password in a second. The Base64 step exists to keep the
colon-separated pair intact inside a header, not to protect it.
Base64URL is a different alphabet
Standard Base64 (RFC 4648 §4) uses + and /, which
have meaning inside a URL. Base64URL (RFC 4648 §5) replaces them with
- and _ and usually drops the =
padding. The two encodings carry the same bytes but are not interchangeable
as text: a decoder expecting one will reject or misread the other.
If you need confidentiality
- For data you must be able to read again — use authenticated encryption with a real key, such as AES-GCM through the Web Crypto API.
- For passwords — do not encrypt them at all. Hash them with a password-hashing function such as Argon2id, scrypt or bcrypt, which are deliberately slow and salted.
- For integrity only — a plain hash or HMAC is enough; you do not need encryption to detect a changed file.
The comparison
| Base64 | Encryption | |
|---|---|---|
| Key required | No | Yes |
| Reversible by anyone who sees it | Yes | No |
| Provides confidentiality | No | Yes |
| Typical purpose | Move bytes through text channels | Keep data from being read |
| Wrong tool for | Hiding secrets | Encoding binary as text |
Encode and decode with the Base64 tool. For hashes see the hash generator, and for credentials the password generator.