Indy 9
IdCoderMIME.pas
See Also, Classes, Variables, Constants
Unit: IdCoderMIME.pas

IdCoderMIME.pas contains classes, types, variables, and constants used to implement encoders and decoders for the Base64 encoding scheme as described in the Internet Standards document:

  • RFC 2045, Multipurpose Internet Mail Extensions (MIME), Part One: Format of Internet Message Bodies, Section 6.8 Base64 Content-Transfer-Encoding (http://www.rfc-editor.org/rfc/rfc2045.txt)

The Base64 encoding mechanism is designed to represent arbitrary sequences of byte data in a form that need not be humanly readable. Base64 encoding is almost identical to the mechanism used in Privacy Enhanced Mail (PEM) applications, as defined in

  • RFC 1421 - Privacy Enhancement for Internet Electronic Mail, Part I: Message Encryption and Authentication Procedures (http://www.rfc-editor.org/rfc/rfc1421.txt)

Base64 encoding uses a 64-character subset of US-ASCII, enabling 6 bits to be represented per printable character. An extra character ("=") has special significance in Base64 encoding. Base64 encoding can represent all version of ISO 646, including US-ASCII, and all characters in the subset are also represented identically in EBCDIC.

Base64 encoding represents 24-bit groups of input as output strings of 4 encoded characters. Proceeding from left to right, a 24-bit input group is formed by concatenating 3 8-bit input groups. These 24 bits are then treated as 4 concatenated 6-bit groups, each of which is translated into a single digit in the base64 alphabet.

Each 6-bit group is used as an index into an array of 64 printable characters. The character referenced by the index is placed in the output string. These characters are selected to be universally representable, and the set excludes characters with particular significance to SMTP (".", CR, LF) and to the multipart boundary delimiters defined in RFC 2046 ("-"). The following table identifies characters and encodings for the Base64 Alphabet:

      Value Encoding  Value Encoding
      0     A         34    i
      1     B         35    j
      2     C         36    k
      3     D         37    l
      4     E         38    m
      5     F         39    n
      6     G         40    o
      7     H         41    p
      8     I         42    q
      9     J         43    r
      10    K         44    s
      11    L         45    t
      12    M         46    u
      13    N         47    v
      14    O         48    w
      15    P         49    x
      16    Q         50    y
      17    R         51    z
      18    S         52    0
      19    T         53    1
      20    U         54    2
      21    V         55    3
      22    W         56    4
      23    X         57    5
      24    Y         58    6
      25    Z         59    7
      26    a         60    8
      27    b         61    9
      28    c         62    +
      29    d         63    /
      30    e         (pad) =
      31    f
      32    g
      33    h

Base64-encoded output must be represented in lines of no more than 76 characters each. All line breaks or other characters not found in the Base64 alphabet must be ignored by decoding software.


Created with Doc-O-Matic 2 donated to Project JEDI. Commercial license available from the Doc-O-Matic site.