,

Simplest base64 conversion in Orchestrator [CB10129]

Learn the simplest and tidiest way to base64 encode decode strings in Aria Automation Orchestrator.

By

min read

Simplest base64 conversion in Orchestrator [CB10129]

I found this little trick to quickly convert a string to base64 and decode it back if needed inside Orchestrator.

While working with REST APIs, you might find trouble converting the credentials into base64 format inside Orchestrator. You might have used either the Crypto plugin or perhaps any module in the polyglot or even tried to refactor any existing JavaScript scrpt to work with Orchestrator. Too much work, I guess!

Note The Base64 encoding technique is a method to convert data, including binary data sets, into ASCII character sets. It is necessary to realize that base64 encoding is not a method to compress or encrypt data.

Base64 Encode

Simply, inside an action or workflow, Select Runtime Environment as Node.js 18 and paste this script. This will convert plainString to base64 format.

exports.handler = (context, inputs, callback) => {
    return (Buffer.from(inputs.plainString).toString('base64'));
}
JavaScript

That’s exactly same with the result I got from base64encode.org

Base64 Decode

You can convert the base64 encoded string back to plain string using this script inside a Node.js 18 action.

exports.handler = (context, inputs, callback) => {
    return (Buffer.from(inputs.base64String, "base64").toString('ascii'));
}
JavaScript

Leave a Reply

Related Posts

%d