Calcul 100% dans le Navigateur • Zéro Journal Serveur • Exécution Instantanée
Curious TechieBoîte à Outils
Data Formats & EncodingsRFC 4648Verified Terminology

Base64 Encoding

Réponse Directe

A binary-to-text encoding scheme that translates raw 8-bit binary octets into a sequence of 64 printable ASCII characters, ensuring safe transport across text-only protocols.

Entity Relationships (GEO Conceptual Hierarchy)

Taxonomy Model
Relational Knowledge Graph Sequence
Base64 Encoding→
binary-to-text radix-64 conversion→
6-bit chunking→
printable ASCII safe transport→
URL-safe alphabet substitution→
33 percent size overhead
Base64 Encoding
•>binary-to-text radix-64 conversion
•>6-bit chunking
•>printable ASCII safe transport
•>URL-safe alphabet substitution
•>33 percent size overhead

Technical Explanation & Operational Mechanics

Many legacy internet protocols (such as SMTP for email or HTTP headers and JSON strings) were designed strictly for 7-bit ASCII characters. Transmitting raw binary data directly can cause control characters (like null bytes or line breaks) to be corrupted or truncated. Base64 divides input data into 6-bit groups (since 2^6 = 64). Each 6-bit value maps to a standard character set: A–Z, a–z, 0–9, plus (+) and slash (/). A URL-safe variant (RFC 4648 §5) replaces + and / with - and _ so tokens can be embedded in URLs and JWTs without percent-encoding. Because 3 bytes (24 bits) are converted into 4 characters (32 bits), Base64 incurs a deterministic ~33.3% size overhead.

Technical Example & Practical Implementation

3-Byte to 4-Character Bitwise Mapping

How 24 bits of binary input are split into four 6-bit Base64 indices

Input String: "Man"
ASCII Hex:    0x4D        0x61        0x6E
Binary (8b):  01001101    01100001    01101110
Combined:     010011010110000101101110 (24 bits)

Split into 6-bit chunks:
Chunk 1:      010011 -> Decimal 19 -> Base64 Character 'T'
Chunk 2:      010110 -> Decimal 22 -> Base64 Character 'W'
Chunk 3:      000101 -> Decimal 5  -> Base64 Character 'F'
Chunk 4:      101110 -> Decimal 46 -> Base64 Character 'u'

Resulting Base64 String: "TWFu"