Base 64 Encode
Table of Contents
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:
| Parameters | Data type | Description |
|---|---|---|
| <response> | TEXT | Variable that stores the Base64 encoded value returned as the response |
| <data> | TEXT / FILE | Represents 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
|
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:
responseThe 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:
responseThe TEXT response that represents the base 64 encoded data
sample_fileThe FILE that holds the pdf file fetched from the web that needs to be encoded