Base64 is an encoding scheme (with some variations in the presentation) that represents binary data in an ASCII string format.
Base64 is a group of similar encoding schemes that represent binary data in an ASCII string format by translating it into a radix-64 representation. The Base64 term originates from a specific MIME content transfer encoding.
Base64 uses characters
z to represent digits of 64-decimal numbers. The last two required digits differ between schemas. For instance, MIME (RFC 2045) uses
/ , XML names tokens use
., XML identifies use
: and regular expressions use
When encoding in Base64 text, 3 bytes are typically encoded into 4 characters. To encode arbitrary lengths, the padding character (
=) is used.
= at the end of encoded sequence means that only two bytes and
== means that only one byte is encoded by the last 4 character group.
Characters outside the discussed alphabet are normally forbidden, except in MIME where they are discarded.
Base64 encoding schemes are commonly used when there is a need to encode binary data that need to be stored and transferred over media that are designed to deal with textual data. This is to ensure that the data remain intact without modification during transport. Base64 is commonly used in a number of applications including email via MIME, and storing complex data in XML.