Overview

base64_encode_fromarray

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.

Usage#

Syntax#

base64_encode_fromarray(array)

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 isn't 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

['sample-http-logs']
| extend ip_bytes = dynamic([192, 168, 0, 1])
| extend encoded_ip = base64_encode_fromarray(ip_bytes)
| project _time, id, method, uri, encoded_ip

Run in Playground

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.

  • 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.

Other query languages#

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.

Splunk example

| eval encoded=custom_base64_encode(byte_array_field)

APL equivalent

datatable(bytes: dynamic)
[
  dynamic([192, 168, 1, 1])
]
| extend encoded = base64_encode_fromarray(bytes)
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).

SQL example

SELECT TO_BASE64(BINARY 'data') AS encoded;

APL equivalent

datatable(bytes: dynamic)
[
  dynamic([192, 168, 1, 1])
]
| extend encoded = base64_encode_fromarray(bytes)

Updated

Was this page helpful?