EncodeBase64 and DecodeBase64 Server Code System Libraries

Introduction

Encoding to base64 is widely used for Basic authentication and it is now added to the Appery.io system libraries.
And so is decoding just in case :)

In this document, we will show how you can use these system libraries in the script.

📘

Note

You can find more examples in the MailgunEmail Server Code plugin.

  1. Create a new Server Code script:
1107
  1. Name the script to TestEncodeDecodeLibs and replace the default script with the below sample code and save:
const user = "test";
const pass = "123";
const encoded = encodeBase64(user + ":" + pass);
console.log("encoded: " + encoded);
const decoded = decodeBase64(encoded);
console.log("decoded: " + decoded);

Here is how the new script should look like:

595
  1. Go to the script Dependencies tab and select the libraries:
  • EncodeBase64
  • DecodeBase64:
1239
  1. Then go back to the script Run tab and test your script:
1239