Base64 Encoder/Decoder
About Base64 Encoding
Base64 is a binary-to-text encoding scheme that represents binary data in an ASCII string format by translating it into a radix-64 representation. It is designed to carry data stored in binary formats across channels that only reliably support text content.
How Base64 Encoding Works
Base64 encoding follows these steps:
- The input data is split into groups of 3 bytes (24 bits).
- Each 24-bit group is split into four 6-bit chunks.
- Each 6-bit chunk (values 0-63) is mapped to a character in the Base64 alphabet.
- If the last group has fewer than 3 bytes, padding '=' characters are added.
Base64 Character Sets
There are two common Base64 character sets:
- Standard Base64: Uses A-Z, a-z, 0-9, +, and / with = as padding
- URL-safe Base64: Similar to standard but uses - and _ instead of + and /
Common Use Cases
- Encoding binary data in emails (MIME)
- Embedding image data in CSS or HTML
- Storing complex data in URLs
- Transmitting binary data in XML/JSON
Technical Details
The encoding process in detail:
Text: H e l l o
ASCII: 72 101 108 108 111
Bits: 001001000110010101101100011011000110111100
Groups: 001001 000110 010101 101100 011011 000110 111100
Decimal: 9 6 21 44 27 6 60
Base64: J G V s b G 8