Base64
Dan Tobias (Talk | contribs) |
(Change primary category to Transfer Encodings) |
||
Line 1: | Line 1: | ||
{{FormatInfo | {{FormatInfo | ||
− | |subcat= | + | |subcat=Transfer Encodings |
}} | }} | ||
− | + | '''Base64''' is one of the two transfer encodings used in [[MIME]] e-mail messages to encode binary data entirely in characters of the 7-bit [[ASCII]] range so that it could be safely transmitted even through systems not supporting anything else (which was more of an issue in the 1970s when e-mail protocols were defined than at present). The other encoding is [[Quoted-printable]], which is best suited for data that is mostly ASCII text but may have a few "unsafe" characters needing encoding. Base64 is best suited for binary data where all byte values from 0 to 255 are likely to occur, and encodes them efficiently (but not easily readably by the "naked eye"). | |
− | '''Base64''' is one of the two transfer encodings used in [[ | + | |
A Base64-encoded message part is indicated in its MIME headers (following the '''Content-type''' header giving the type of data) with the line: | A Base64-encoded message part is indicated in its MIME headers (following the '''Content-type''' header giving the type of data) with the line: | ||
Line 30: | Line 29: | ||
* [[Wikipedia:MIME#Content-Transfer-Encoding|Content Transfer Encoding (Wikipedia)]] | * [[Wikipedia:MIME#Content-Transfer-Encoding|Content Transfer Encoding (Wikipedia)]] | ||
* [[Wikipedia:Base64|Base64 (Wikipedia)]] | * [[Wikipedia:Base64|Base64 (Wikipedia)]] | ||
+ | |||
+ | [[Category:E-Mail, newsgroups, and forums]] |
Revision as of 22:55, 24 August 2014
Base64 is one of the two transfer encodings used in MIME e-mail messages to encode binary data entirely in characters of the 7-bit ASCII range so that it could be safely transmitted even through systems not supporting anything else (which was more of an issue in the 1970s when e-mail protocols were defined than at present). The other encoding is Quoted-printable, which is best suited for data that is mostly ASCII text but may have a few "unsafe" characters needing encoding. Base64 is best suited for binary data where all byte values from 0 to 255 are likely to occur, and encodes them efficiently (but not easily readably by the "naked eye").
A Base64-encoded message part is indicated in its MIME headers (following the Content-type header giving the type of data) with the line:
Content-Transfer-Encoding: Base64
The data is encoded as a sequence of base-64 digits, consisting of a character from a set of 64 characters, which (starting at the character representing zero) goes in the order:
- Capital letters from A to Z
- Lowercase letters from a to z
- Digits from 0 to 9
- The characters + and /
A base-64 digit (fitting in one byte of the encoded data) encodes six bits of the original data. Since a byte has eight bits, three bytes of the original file (24 bits) correspond to four base-64 digits. Thus, the encoding method requires you to consider each group of three bytes as a number (big-endian), and express it as four digits in the base-64 system. The padding character = is used to fill out a group of four characters if not needed to encode the end of the original data.
BinHex uses a similar encoding scheme (except for really early versions which used hexadecimal as implied by the name), but with a different set of 64 characters and some other format differences.