Base 64 Encoding
Base 64 encoding, described in detail in RFC 2045, provides a simple way to translate binary data into an ASCII format suitable for use with the SMTP protocol. The encoding process generates four characters of encoded data for each three bytes of original data.
A base 64 encoder reads the byte sequence of the original data six bits at a time. Each six-bit value is encoded as one of 64 printable characters. After encoding, the encoder arranges the printable output in lines of 72 characters each. The result is a message that any RFC 822-compliant mail system can process without loss of data.
RWMimeUtils provides static utility functions, including a base 64 encoder. To encode data in base 64 format, use the encode() function with RWMimeUtils::Base64 as the second argument, for example:
 
RWCString binaryData;
 
// ... fill the RWCString with binary data
 
RWCString encoded = RWMimeUtils::encode(binaryData,
RWMimeUtils::Base64);
Likewise, to decode base 64 encoded data, use the decode() function from RWMimeUtils, as shown:
 
RWCString encoded;
 
// ... fill the RWCString with base 64 encoded data
 
RWCString binaryData = RWMimeUtils::decode(encoded,
RWMimeUtils::Base64);