跳到主要内容
uencoder

如何Base64 Decode Text

Learn 到反转 Base64 字符串回 到其 原始 form, including 如何处理 padding 和无效 characters.

问题

你有 received Base64-encoded 字符串和 need 到 recover 原始 plain 文本或 二进制数据.

前置条件

  • Understanding 的 Base64 alphabet
  • Ability 到 recognize padding characters

步骤

  1. 1. Inspect the Base64 string

    Confirm the string only contains valid Base64 characters (A-Z, a-z, 0-9, +, /) and optional = padding. Remove any whitespace or line breaks that may have been inserted for readability.

    输入
    SGVsbG8sIFdvcmxkIQ==
    输出
    clean string
  2. 2. Decode the string

    Pass the cleaned string to a Base64 decoder. The decoder maps each character back to a 6-bit value, concatenates the bits, and splits them into 8-bit bytes.

    输入
    SGVsbG8sIFdvcmxkIQ==
    输出
    Hello, World!
  3. 3. Interpret the result

    If the original data was text, display it as text using the correct character set. If it was binary, save it as a file or inspect the bytes. A garbled result usually means the wrong charset was assumed.

    输入
    SGVsbG8sIFdvcmxkIQ==
    输出
    Hello, World!

预期结果

原始文本或 二进制数据, identical 到什么是 encoded 之前.

常见错误

Decoding fails with 'invalid length'
The string is not a multiple of 4. Add the missing = padding characters or re-encode the source.
Output is garbled or shows replacement characters
The original data was binary or used a different character set. Decode as bytes and inspect the raw output.

排障指引

  • Strip all whitespace before decoding.
  • If the string came from a URL, replace - with + and _ with / (URL-safe Base64) first.

安全限制

  • Decoding Base64 reveals the original data instantly. Do not treat Base64 as a security barrier.

相关工具

相关词条

参考链接