Base64 stellt Binärdaten mit vierundsechzig druckbaren Zeichen dar, damit etwas, das kein Text ist, durch einen Kanal reisen kann, der nur Text befördert — einen E-Mail-Text, ein JSON-Feld, eine Data-URL in einem Stylesheet. Es ist eine Kodierung, keine Verschlüsselung: Die Umwandlung ist öffentlich, von jedem umkehrbar und bietet nicht den geringsten Schutz.
Text wird vor dem Kodieren in UTF-8-Bytes umgewandelt und nach dem Dekodieren zurück, und genau das lässt Buchstaben mit Akzent, andere Schriften und Emoji den Hin- und Rückweg überstehen, statt entstellt zurückzukommen. Drei Bytes Eingabe werden zu vier Zeichen Ausgabe, alles so Kodierte wächst also um etwa ein Drittel.
Wofür es da ist und wofür nicht
-
Es ist keine Sicherheitsmaßnahme:
Kodierung verbirgt nichts. Jeder kann eine base64-Zeichenkette in Sekunden dekodieren, und ein so gespeichertes Passwort oder ein Schlüssel liegt offen sichtbar.
-
Die Ausgabe ist rund ein Drittel größer als die Eingabe:
was bei Data-URLs zählt. Ein großes Bild als base64 einzubetten macht das Stylesheet oder Dokument größer als die Datei, die es ersetzt hat.
-
Die URL-sichere Variante nutzt ein anderes Alphabet:
Tokens und URL-Parameter verwenden oft Bindestrich und Unterstrich, wo Standard-base64 Plus und Schrägstrich nutzt. Ohne vorherige Rückumwandlung lassen sie sich hier nicht dekodieren.
-
Leerraum und Zeilenumbrüche überstehen es meist:
Viele Systeme brechen langes base64 bei fester Breite um. Eingefügte Zeilenumbrüche toleriert der Decoder im Allgemeinen, eine abgeschnittene Zeichenkette nicht.
What base64 is actually for
Base64 exists to let data that is not text travel through a channel built only to carry text — an email body, a JSON field, a data URL sitting inside a stylesheet. The [msm_tool slug="base64-encoder-decoder"] represents that data using sixty-four printable characters chosen specifically because every one of them survives untouched through systems that would otherwise mangle raw bytes.
An encoding, not a form of protection
The transformation is entirely public and reversible by anyone, with no key involved anywhere in the process. A password or an API key stored as base64 is not hidden in any meaningful sense — it is stored in plain sight, one decode away from being read by whoever finds it.
The output is always about a third larger
Every three bytes of input become four characters of output, which is a fixed, inherent property of the format rather than something that varies by content. That growth matters most for data URLs: inlining a large image as base64 can leave the surrounding stylesheet or document bigger than the original file it was meant to replace.
Text survives the round trip because of an extra step
Text is converted to UTF-8 bytes before encoding and converted back afterwards, which is what lets accented characters, other scripts and emoji come back exactly as they went in rather than arriving mangled. The encoding itself only ever deals in bytes; the UTF-8 conversion is what connects it back to readable text.
The URL-safe variant is a genuinely different alphabet
Tokens and URL parameters commonly use a variant where dash and underscore replace the plus and slash that standard base64 uses, specifically because plus and slash have their own meaning inside a URL. A string encoded that way will not decode correctly here without converting those characters back to the standard alphabet first.
Whitespace tolerance versus a truncated string
Many systems wrap long base64 output at a fixed line width, and those line breaks are generally tolerated when pasted back in for decoding. A string that has been cut off partway through is a different problem entirely — decoding can only work on what is actually complete.