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 uses a set of 64 characters (A-Z, a-z, 0-9, + and /) to represent binary data, with = used for padding. This encoding is essential when you need to encode binary data that needs to be stored and transferred over media that are designed to deal with text.
Base64 encoding works by taking three bytes of binary data (24 bits) and representing them using four Base64 characters (6 bits each). If the input length is not divisible by three, padding characters (=) are added to ensure proper decoding. This results in an encoded string that is approximately 33% larger than the original binary data.