Base64 encryption is a lie

发布于

本指南内容

Calling Base64 “encryption” is dangerous. Encoded passwords, API keys and tokens are still readable by anyone who pastes them into a decoder.

This article shows real leak patterns and what to use instead: HTTPS, password hashing, and proper secret storage.

After reading, try the JWT decoder and secret redactor — both run locally in your browser.

接着试用这些私密工具

Search for “Base64 encryption” and you will find thousands of questions, tutorials and even production code that treat Base64 as a way to protect data. It is not. Base64 is an encoding: a reversible, public, key-less transformation. Calling it encryption is like calling a translation into French “encryption”.

A two-second “attack”

cGFzc3dvcmQxMjM=

Paste it into any Base64 decoder and you get password123. No key, no brute force, no skill. Anyone who sees the value knows the secret.

Where people get hurt

  • Kubernetes Secrets. The values in a Secret manifest are Base64-encoded, so many people assume they are encrypted. They are not: anyone with read access to the manifest (or a Git repository where it was committed) has the plaintext. Use encryption at rest, sealed secrets or an external secret manager.
  • HTTP Basic authentication. Authorization: Basic dXNlcjpwYXNz is just user:pass. Basic auth is acceptable only over HTTPS. Decode such a header with the Basic Auth decoder to see for yourself.
  • JWT payloads. The payload of a JSON Web Token is readable by anyone who has the token. The signature prevents modification, not reading. Never put secrets in a JWT payload — check what yours contain with the JWT decoder.
  • “Obfuscated” API keys in mobile apps and front-end code. Base64-encoding a key in a JavaScript bundle protects nothing; automated scanners decode Base64 routinely.
  • Configuration files and URLs with “encrypted” passwords that are really just Base64.

Encoding vs encryption vs hashing

Purpose Needs a key? Reversible? Examples
Encoding Represent data in another format No Yes, by anyone Base64, hex, URL encoding
Encryption Keep data confidential Yes Only with the key AES-GCM, ChaCha20, RSA
Hashing Fingerprint / verify data No No SHA-256, bcrypt, Argon2

What to use instead

  • Storing passwords: hash them with Argon2id, bcrypt or scrypt. Never encrypt or encode passwords.
  • Protecting data: encrypt with a vetted library (libsodium, the Web Crypto API, your platform’s KMS) using authenticated encryption such as AES-GCM.
  • Transmitting data: use TLS (HTTPS).

Base64 still has a role here: encrypted data and hashes are binary, and Base64 is a great way to store that ciphertext in JSON or a database text column. Just remember the order: encrypt first, then encode.

常见问题

Can Base64 hide my password?

No. Decoding Base64 needs no secret. Never store or transmit passwords as Base64 alone.

Is Base64URL safer?

No. Base64URL only changes the alphabet for URLs; it is still encoding, not encryption.

相关工具和指南

评论 (0)

对“Base64 encryption is a lie”有疑问、想法或发现了 bug?欢迎留言评论、为工具评分或回复他人。

暂无评论,快来分享您的反馈吧!

发表评论

为此工具评分:
Esc
↑ ↓ 移动↵ 打开Esc 关闭