Skip to content

encodeBase64 - Encode a base64 string

encodeBase64 will transform a string into its Base64 encoded value.

Syntax

Like many functions in DataPrime, encodeBase64 supports two notations, function and method notation. These interchangeable forms allow flexibility in how you structure expressions.

encodeBase64(value: string): string
value: string.encodeBase64(): string

Arguments

NameTypeRequiredDescription
valuestringtrueThe string to be base64 encoded

Example - Encoding URLs into Base64

It's common to send data that contains special or reserved characters, like URLs, in Base64 encoded format, to ensure there are no parsing issues.

{
    "path": "/home",
    "domain": "coralogix.com",
    "full_url": "https://coralogix.com/home"
}

If we want to view to basse64 encode our full_url value, we can use encodeBase64:

create full_url_encoded from encodeBase64(full_url)
create full_url_encoded from full_url.encodeBase64()

The resulting document will look like this:

{
    "path": "/home",
    "domain": "coralogix.com",
    "full_url_encoded": "aHR0cHM6Ly9jb3JhbG9naXguY29tL2hvbWU=",
    "full_url": "https://coralogix.com/home"
}