Home > Language Reference > Classes > StreamCipher

InitBase64 Method

Sets the encoding/decoding scheme to Base64.

Syntax

Public Sub InitBase64(Optional ByRef sEOL As String = "")

ParameterDescription
sEOLString used as end-of-line characters.

Remarks

The InitBase64 method sets the encoding/decoding scheme to Base64, and allocates the necessary internal buffers. If the object was already initialized, buffers allocated for the previous encoding scheme are freed, and any pending data are lost.

The Base64 algorithm is a standard format used to represent binary data using only 7-bits ASCII characters. It is widely used to encode mail attachments, for example. The encoding process represents 24-bit groups of input bits 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. This alphabet only contains characters that are universally representable, and excludes characters with particular significance to SMTP or POP3 protocols. Detailed information on this are available online, in the RFC 1341 document.

By default, the StreamCipher object outputs encoded data as a single line of characters. However, some protocols (such as SMTP) require that no line exceeds 76 characters. In such a case, you can specify a value for the sEOL parameter. This string will be automatically inserted into the output stream every 72 characters. Typically, you'll specify "\n" or "\r\n" for this value.

When reading, the StreamCipher object skips any blank character, such as spaces, line feeds, carriage returns, or tabulations. An end-of-file condition occurs either when the physical end-of-file is reached, or either when a characters that does not belong to the Base64 alphabet is encountered.

You can refer to the Flush method for an example of using this encoding scheme to write a mail attachment.

System requirements

SystemMinimal versionRemarks
Palm OSPalm OS 3.0N/A