Base64 是什么

澄清 Base64 不是加密而是编码,并用真实场景说明它在接口与文本传输中的作用。

原始文档标题: Base64 是什么

章节 1

Base64 is a way of encoding binary data as text. When people first see Base64, it often looks like a long string of letters, numbers, slashes, plus signs, and equals signs, so it is easy to mistake it for encryption. But Base64 is not encryption. It does not protect data. Its purpose is to convert binary content into a text-safe form that can travel through systems that handle text more comfortably than raw bytes.

章节 2

Why is that useful? Because many systems, protocols, and formats are built around text. JSON request bodies, configuration files, logs, HTML, CSS, and email content often prefer text-friendly payloads. If you want to embed a small image, file fragment, or byte sequence directly inside one of these environments, Base64 is a common option. Data URLs in web pages are a familiar example, where an image can be embedded directly into markup instead of being loaded as a separate file request.

章节 3

One thing that must be explained clearly is that Base64 provides no real security. Anyone with a basic decoding tool can turn a Base64 string back into its original content. That means Base64 is not a substitute for encryption, signatures, access control, or privacy protection. Beginners often confuse it with hiding data because the output looks unreadable, but that is only because it is encoded, not protected.

章节 4

On a tools website, Base64 features often include text to Base64, Base64 to text, image to Base64, Base64 to image, and URL-safe Base64 variants. People use these tools not because they want a theory lesson, but because they have a specific problem in front of them: an API parameter looks strange, a front-end payload contains a long encoded string, or a `data:image/...` value needs to be turned back into a normal image. The most helpful explanation of Base64 always puts it back into those real-world cases: it is a bridge between binary content and text-first environments.