base64: Base64 encoding and decoding

This module contains functions for base64 encoding and decoding of arbitrary narrow binary strings. Base64 allows representing arbitrary binary data using only a limited set of printable ASCII characters. Base64 encoding can be used, for example, in encoding email messages and in parts of the HTTP protocol.

The base64 alphabet contains the following characters (but = is only used for padding):

A B C ... Z a b c ... z 0 1 2 3 ... 9 + / =

The Base64 encoding is defined in RFC 4648.

Functions

Base64Encode(str as Str) as Str
Return the base64 encoded form of the input string. The input string may be an arbitrary narrow binary string.
Base64Decode(str as Str) as Str
Return the decoded form of the input string. The input must be a valid base64 encoded string.

Note: Non-alphabet characters in the input string, including whitespace characters, generate an exception.

Examples

Base64Encode("Alore")     -- Result: "QWxvcmU="
Base64Decode("QWxvcmU=")  -- Result: "Alore"