Base64

From Just Solve the File Format Problem
(Difference between revisions)
Jump to: navigation, search
(Created page with "{{FormatInfo |subcat=E-Mail, newsgroups, and forums }} '''Base64''' is one of the two transfer encodings used in MIME e-mail messages to encode binary data entirely in charac...")
 
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{FormatInfo
 
{{FormatInfo
|subcat=E-Mail, newsgroups, and forums
+
|formattype=electronic
 +
|subcat=Transfer Encodings
 +
|image=Base64.png
 
}}
 
}}
 
+
'''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 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:
 
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 16: Line 17:
 
* The characters + and /
 
* 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.
+
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 ([[Endianness|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.
 
[[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.
  
== References ==
+
== Specs ==
* [Content Transfer Encoding (Wikipedia)]
+
* [http://en.wikipedia.org/wiki/Base64 Base64 (Wikipedia)]
+
 
* RFC 3548
 
* RFC 3548
 
* RFC 4648
 
* RFC 4648
 +
 +
== Software ==
 +
* [https://www.gnu.org/software/coreutils/coreutils.html GNU Coreutils] → [https://www.gnu.org/software/coreutils/manual/html_node/base64-invocation.html base64]
 +
* [http://www.base64encode.org/ Base64 online encoder/decoder]
 +
* [http://search.cpan.org/~gaas/MIME-Base64-3.14/Base64.pm Base64 module for Perl]
 +
 +
== Other links ==
 +
* [[Wikipedia:MIME#Content-Transfer-Encoding|Content Transfer Encoding (Wikipedia)]]
 +
* [[Wikipedia:Base64|Base64 (Wikipedia)]]
 +
 +
[[Category:E-Mail, newsgroups, and forums]]

Latest revision as of 16:52, 11 December 2015

File Format
Name Base64
Ontology

{{{caption}}}

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.

[edit] Specs

[edit] Software

[edit] Other links

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox