Perform Base64 Decoding of a Field
Perform Base64 decoding of a field using
base64Decode()
function
Query
decoded := base64Decode(encoded)
Introduction
Base64 is used to encode binary data as printable text. This allows you to transport binary over protocols or mediums that cannot handle binary data formats and require simple text. For example, encoding an attachment as Base64 before sending, and then decoding when received, assures older SMTP servers will not interfere with the attachment.
In this example, the base64Decode()
function is
used to manipulate character strings that are base64 encoded and return
a base64-decoded version of the input string.
Step-by-Step
Starting with the source repository events.
- flowchart LR; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% repo{{Events}} 0>Augment Data] result{{Result Set}} repo --> 0 0 --> result style 0 fill:#ff0000,stroke-width:4px,stroke:#000;logscale
decoded := base64Decode(encoded)
Decodes the
Base64
value in encoded and stores it in the field decoded (the field on which to decodeBase64
values). The decoded value is subsequently decoded as binary representation of a string according to thecharset
parameter. Thecharset
parameter is the character set to use when transforming bytes to string. To work with binary data, useISO-8859-1
character set. Event Result set.
Summary and Results
The query is used to filter on input fields that do not contain a valid Base64 encoding. When decoding to a code point that is invalid with respect to the selected charset, the invalid code point is replaced with a placeholder character. This process ensures that data can be easily processed by computers.