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.
For users of other query languages
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 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 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).Usage
Syntax
Parameters
Name | Type | Required | Description |
---|---|---|---|
array | dynamic | ✔️ | A dynamic array of integers between 0 and 255 representing byte values. |
Returns
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.Example
Use this function to encode request metadata for logging or comparison with external systems that require Base64-encoded fields. Query_time | id | method | uri | encoded_ip |
---|---|---|---|---|
2025-06-25T08:00:00Z | user123 | GET | /api/data | wKgAAQ== |
List of related functions
- array_concat: Concatenates arrays of bytes or values. Use this when building byte arrays for Base64 encoding.
- base64_decode_toarray: Decode a Base64-encoded string into an array of bytes. Use this when decoding data received from external sources.
- format_ipv4_mask: Formats a raw IPv4 address with an optional prefix into CIDR notation. Use when dealing with IP-to-string transformations.
- parse_ipv4: Parses a string representation of an IP address into its numeric form. Use this before encoding or masking IP addresses.