This page explains how to use the base64_encode_fromarray function in APL.
Use the base64_encode_fromarray
function to convert a sequence of bytes into a Base64-encoded string. This function is useful when you need to transform binary data into a textual representation for safe storage, logging, or transmission—especially over protocols that require plain-text formats.
You can apply this function when working with IP addresses, file contents, or any byte array that needs to be encoded for use in logs or APIs. It accepts a byte array and returns the Base64-encoded string representation of that array.
If you come from other query languages, this section explains how to adjust your existing queries to achieve the same results in APL.
Splunk SPL users
Splunk doesn’t provide a native function to directly encode an array of bytes into Base64 in SPL. You would typically write a custom script using an external command or use eval
with a helper function in an app context.
ANSI SQL users
ANSI SQL doesn’t define a built-in standard for Base64 encoding from an array of bytes. This is usually handled via vendor-specific functions (e.g., TO_BASE64()
in MySQL, or encode()
in PostgreSQL).
Name | Type | Required | Description |
---|---|---|---|
array | dynamic | ✔️ | A dynamic array of integers between 0 and 255 representing byte values. |
If successful, returns a string representing the Base64-encoded version of the input byte array. If the input is not a valid array of bytes, the result is an empty string.
Use this function to encode request metadata for logging or comparison with external systems that require Base64-encoded fields.
Query
Output
_time | id | method | uri | encoded_ip |
---|---|---|---|---|
2025-06-25T08:00:00Z | user123 | GET | /api/data | wKgAAQ== |
Encodes a hardcoded byte representation of an IP address into Base64 for easy string-based comparison or logging.