Base64 kodlama, 64 ASCII karakterinden (A-Z, a-z, 0-9, +, /) oluşan bir set kullanarak 8 bitlik ikili verileri 6 bitlik karakterlere dönüştürür. Her 3 bayt giriş verisi 4 Base64 karakterine dönüştürülür ve bu da veri boyutunu yaklaşık %33 artırır.
- Step 1 - Group into 3-byte blocks: The input data is divided into groups of 3 bytes (24 bits).
- Step 2 - Split into 6-bit segments: Each 24-bit block is split into four 6-bit segments.
- Step 3 - Map to Base64 characters: Each 6-bit value (0-63) is mapped to one of 64 ASCII characters: A-Z (values 0-25), a-z (26-51), 0-9 (52-61), + (62), / (63).
- Step 4 - Padding: If the input length isn't divisible by 3, padding characters (=) are added to make the output length a multiple of 4.
Example: The string "cat" (ASCII: 99, 97, 116) encodes to "Y2F0". The bytes [99, 97, 116] become binary 01100011 01100001 01110100, which splits into 6-bit groups: 011000 110110 000101 110100, mapping to Y(24) 2(54) F(5) 0(52).