Zum Inhalt springen
uencoder

Wie in Base64 Kodieren Text

Schritt-durch-Schritt Leitfaden in Kodierung plain Text in Base64, covering padding Regeln und gemein verwenden cases.

问题

You brauchen in konvertieren ein plain-Text Zeichenkette in ein Base64 representation also it kann sein safely transported über Text-nur channels such als JSON, XML, oder HTTP headers.

Voraussetzungen

  • Basic understanding of ASCII and binary
  • Familiarity with a terminal or online encoder

Schritte

  1. 1. Prepare the input text

    Write down or paste the exact text you want to encode. Make sure there are no trailing newline characters unless you intentionally want them encoded. Even a hidden line break will change the output.

    Eingabe
    Hello, World!
    输出
    SGVsbG8sIFdvcmxkIQ==
  2. 2. Encode the text to Base64

    Feed the text into a Base64 encoder. The encoder splits the byte stream into 6-bit groups and maps each group to one of 64 printable characters. The output length is always a multiple of 4 characters.

    Eingabe
    Hello, World!
    输出
    SGVsbG8sIFdvcmxkIQ==
  3. 3. Verify the padding

    Check that the result ends with zero, one, or two '=' padding characters. Padding ensures the total length is a multiple of 4. If the output length is not divisible by 4, the encoding is invalid.

    Eingabe
    SGVsbG8sIFdvcmxkIQ==
    输出
    valid (length 16, divisible by 4)

Erwartetes Ergebnis

Ein Base64 Zeichenkette das ist ein multiple von 4 Zeichen in Länge, containing nur Ein-Z, ein-z, 0-9, +, /, und = padding.

Häufige Fehler

Output contains spaces or line breaks
Some encoders insert line breaks every 76 characters (MIME style). Use a raw Base64 encoder or strip whitespace before using the result.
Decoding produces extra characters
An invisible trailing newline was encoded. Trim the input before encoding if you do not want it.

Troubleshooting指引

  • If the output is not a multiple of 4, re-run the encoder with the same input and check for truncation.
  • Compare your result with an independent encoder to rule out character-set mismatches.

Sicherheitsgrenzen

  • Base64 is encoding, not encryption. Anyone can decode it. Never use it to protect secrets.

Verwandte Tools

Verwandte Begriffe

参考链接