Cómo a Base64 Decodificar Texto
Aprender a invertir un Base64 cadena back a its original form, incluyendo cómo a handle padding y inválido caracteres.
问题
You tener received un Base64-encoded cadena y necesitar a recover el original plain texto o binary datos.
Requisitos previos
- Understanding of Base64 alphabet
- Ability to recognize padding characters
Pasos
-
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.
entradaSGVsbG8sIFdvcmxkIQ==输出clean string -
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.
entradaSGVsbG8sIFdvcmxkIQ==输出Hello, World! -
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.
entradaSGVsbG8sIFdvcmxkIQ==输出Hello, World!
Resultado esperado
El original texto o binary datos, identical a qué was encoded antes.
Errores comunes
- 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.
Solución de problemas指引
- Strip all whitespace before decoding.
- If the string came from a URL, replace - with + and _ with / (URL-safe Base64) first.
Límites de seguridad
- Decoding Base64 reveals the original data instantly. Do not treat Base64 as a security barrier.