什么是 Base64 编码?
Base64 是一种将二进制数据转换为文本字符串的编码方式,广泛应用于在 HTTP 环境下传输数据。它将每 3 个字节编码为 4 个可打印字符,使用 A-Z、a-z、0-9、+、/ 共 64 个字符集。
常见应用场景:
- 在 URL、Cookie 和 HTML 中嵌入图片数据
- 在 JSON 或 XML 中传输二进制数据
- 基本身份验证凭证的编码
- JWT Token 的组成部分
注意:Base64 是编码而非加密,不能用于敏感数据保护。
What is Base64 Encoding?
Base64 is an encoding scheme that converts binary data into a text string, widely used for transmitting data in HTTP environments. It encodes every 3 bytes into 4 printable characters using a 64-character set: A-Z, a-z, 0-9, +, and /.
Common use cases:
- Embedding image data in URLs, cookies, and HTML
- Transmitting binary data in JSON or XML
- Encoding basic authentication credentials
- As a component of JWT Tokens
Note: Base64 is encoding, not encryption — do not use it for protecting sensitive data.