BASE64_ENCODE

The function BASE64_ENCODE accepts a String and base64 encodes that string.

While any arbitrary data may be encoded using base64, the BASE64_ENCODE function only encodes Strings. See Encoding in Airscript (URLs & Base64) for more details.

Limitations

The size limit of the string parameter to be encoded is 1MB.

Declaration

BASE64_ENCODE(string) -> encoded_string

Parameters

string (type: string)
The string to be encoded as base64.

Return Values

encoded_string (type: string)
The base64 encoded string.

Examples

The BASE64_ENCODE function is needed when interacting with an external system that requires a base64 encoded string. For example, although Data Operations take care of most of the hard work for you, certain authentication schemes require an access token to be base64 encoded. Assuming that the variable access_token held the string "top secret!",we might set the Authorization header with this expression.

"Bearer {{BASE64_ENCODE(access_token)}}" -> "Bearer dG9wIHNlY3JldCE="

Discussion

The function BASE64_DECODE is the opposite operation to BASE64_ENCODE. Rather than encoding a String, it will decode it. Encoding, and then decoding a String will produce the original String.

BASE64_DECODE(BASE64_ENCODE("Hello, world")) -> "Hello, world"