EncodeBase64

From Xojo Documentation
Jump to: navigation, search
Method

Converts a String to Base64 format.

Syntax

result=EncodeBase64(str [,lineWrap])

Part Type Description
result String The Base64 representation of str.
str String The String expression to be converted to Base64 format.
lineWrap Integer Specifies the maximum number of characters per line.

The default value is 76, which is the line length specified by the Base-64 Content Transfer Encoding used in MIME. If you specify a value of 0, EncodeBase64 will not insert any linebreaks. Line breaks are always CR + LF regardless of platform.

Notes

Base64 is used for email file attachments. SMTP was designed around the ASCII encoding, so it assumes that characters below ASCII 32 are control codes and it doesn’t expect codes above ASCII 127. EncodeBase64 lets you encode arbitrary binary data into a 64-character alphabet composed of the printable ASCII characters. Three bytes of input become four characters of output. EncodeBase64 is also used in authentication schemes as a way to send an encryption key or hash value through a link that expects text.

The DecodeBase64 function performs the reverse operation, taking a Base64 expression and converting it to the original data.

If you tell EncodeBase64 to line wrap and want a different line ending than CRLF, you'll need to use ReplaceLineEndings as appropriate.

Examples

The following example encodes UTF-8 text for transmission without line breaks.

Dim myText As Text = "Hello, world!"
Dim encodedText As String = EncodeBase64(myText, 0)
// encodedText is "SGVsbG8sIHdvcmxkIQ=="

See Also

Personal tools
Namespaces

Variants
Actions
Main
Content
Starting Out
Dig Deeper
More Help
Toolbox
About