Fix commun Base64 décodage erreurs
Pourquoi un Base64 chaîne fails en décoder — missing padding, URL-sûr alphabets, stray whitespace — et le exact étapes en repair chaque case.
- 1
Base64 encodes every 3 bytes into 4 characters, so a valid string's length (ignoring whitespace) is always a multiple of 4. When a decoder reports INVALID_BASE64, one of three causes is almost always responsible.
- 2 Décodeur Base64 →
Paste the failing string and try decoding with the standard alphabet first. The error message distinguishes invalid characters from invalid length.
- 3
Cause 1 — missing padding: if the length is 2 or 3 modulo 4, append '=' characters until the length is a multiple of 4. Cause 2 — URL-safe alphabet: tokens and URL parameters use '-' and '_' instead of '+' and '/'; swap them before decoding. Cause 3 — stray whitespace or line breaks: strip spaces and newlines that MIME transport may have inserted.
- 4 Encodeur Base64 →
Round-trip check: encode a known plaintext and compare the output with your broken string character by character to spot an alphabet or padding difference.
Questions fréquentes
- Why do some Base64 strings end with '='?
- Padding. When the input is not a multiple of 3 bytes, one or two '=' characters are appended so the output length is a multiple of 4. Padding can sometimes be inferred, but strict decoders require it.
- Is Base64 encryption?
- No. Base64 is a reversible encoding with no secret. It is used to transport binary data through text-only channels, never to protect it.