Base64

From Just Solve the File Format Problem
(Difference between revisions)
Jump to: navigation, search
(References)
Line 20: Line 20:
 
[[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 ==
* [http://en.wikipedia.org/wiki/MIME#Content-Transfer-Encoding Content Transfer Encoding (Wikipedia)]
+
* [http://en.wikipedia.org/wiki/Base64 Base64 (Wikipedia)]
+
 
* RFC 3548
 
* RFC 3548
 
* RFC 4648
 
* RFC 4648
 +
 +
== Programming libraries/modules ==
 +
* [http://search.cpan.org/~gaas/MIME-Base64-Perl-1.00/lib/MIME/Base64/Perl.pm Base64 module for Perl]
 +
 +
== Other links ==
 +
* [http://en.wikipedia.org/wiki/MIME#Content-Transfer-Encoding Content Transfer Encoding (Wikipedia)]
 +
* [http://en.wikipedia.org/wiki/Base64 Base64 (Wikipedia)]

Revision as of 01:54, 24 January 2014

File Format
Name Base64
Ontology

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.

Specs

Programming libraries/modules

Other links

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox