These functions can be used to encode and decode data in base64
. It is particularly used when that data needs to be stored and transferred over media that are designed to deal with text. This encoding and decoding helps to ensure that the data remains intact without modification during transport.
Function | Description |
---|---|
encoding::base64::encode() | This function is used to encode data. |
encoding::base64::decode() | This function is used to decode data. |
encoding::base64::encode()
The encoding::base64::encode()
function encodes a bytes to base64.
API DEFINITIONencoding::base64::encode(bytes) -> string
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN encoding::base64::encode(<bytes>""); true
RETURN encoding::base64::encode(<bytes>"2323"); "MjMyMw"
RETURN encoding::base64::encode(<bytes>"hello"); "aGVsbG8"
encoding::base64::decode()
The encoding::base64::decode()
function decodes a base64 to a string.
API DEFINITIONencoding::base64::decode(string) -> bytes
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN encoding::base64::decode("MjMyMw"); [ 50, 51, 50, 51, ]
You can also verify the output of the encoded value matches the original value.
RETURN encoding::base64::decode("aGVsbG8") = <bytes>"hello"; true