Base 64 Encode

Description

The zoho.encryption.base64Encode task is used to encode data to base 64 format.

Syntax

<response> = zoho.encryption.base64Encode(<data>, <destination_character_set>);

where:

ParametersData typeDescription
<response>TEXTVariable that stores the Base64 encoded value returned as the response
<data>TEXT / FILERepresents the data that needs to be encoded
<destination_character_set>
(Optional)
TEXT

Specifies the character set to be used for Base64 encoding. If not specified, the default character set is applied

Supported Values

  • UTF-8 (Default)
  • UTF-16LE
  • UTF-16BE

Example 1: Encode a text to base 64 format

The following script encodes the text - john@zylker.com to base 64 format.

response = zoho.encryption.base64Encode("john@zylker.com");

where:

response
The TEXT response that represents the base 64 encoded data. This example returns - am9obkB6eWxrZXIuY29t.
"john@zylker.com"
The TEXT that represents the data that needs to be encoded

Example 2: Encode a file to base 64 format

The following script invokes a file from the web and encodes it to base 64 format.

// Fetch a file from the web
sample_file=invokeUrl
[
url:"https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
type:GET
];
// Encode the file content
response=zoho.encryption.base64Encode(sample_file);

where:

response
The TEXT response that represents the base 64 encoded data
sample_file
The FILE that holds the pdf file fetched from the web that needs to be encoded

Related Links