3 ms·
Base64 is groups of six bits of arbitrary binary data, being interpreted as 6 bit integers (valued 0 to 63) which index into a table of 64 printable characters.
by kazinator 9y ago
Base64 is groups of six bits of arbitrary binary data, being interpreted as 6 bit integers (valued 0 to 63) which index into a table of 64 printable characters. That coding then gives the binary data a printed representation that we can store in strings and plain text files.
The ASCII datum "A" doesn't turn to "A" in Base64, and in fact it doesn't turn to any specific Base64 code. In a stream of 8 bit characters where "A" occurs, that "A" byte will be split into two 6-bit groups in one of three ways: 2-6, 4-4 or 6-2. In those groups that get only 2 or 4 bits of that "A", there will likely be other non-zero bits from adjacent characters/data which help determine the code. In base 1024, we have 10 bit units that can be packed with data.
The Base64 code letter "A" is the first entry in the Base64 table table; it corresponds to zero: a sequence of six zero bits.