--- title: "Encode & Decode Actions" slug: "encode-and-decode-actions" description: "This is a list of actions that can be used in RapidIdentity Connect to encode and decode data within the system." tags: ["RapidIdentity ", "Connect", "Actions", "Encode", "Decode"] updated: 2022-06-02T20:48:50Z published: 2022-06-02T20:48:50Z canonical: "help.rapididentity.com/encode-and-decode-actions" --- > ## Documentation Index > Fetch the complete documentation index at: https://help.rapididentity.com/llms.txt > Use this file to discover all available pages before exploring further. # Encode and Decode Actions ## Encode & Decode Actions ### decodeBase64ToBytes Decode Base64 encoded data to a byte array. | Property | Value | Description | | --- | --- | --- | | data* | expression, variable | data to decode | | returnVariable | expression, variable | name of the variable to be assigned to the return value | ```actionscript userXML = loadFileAsXML("users/user.dsml") photoBytes = decodeBase64ToBytes(userXML.photo[0]); saveToFile("user.jpg", photoBytes) ``` ### decodeBase64ToString Decode Base64 encoded data to a string. | Property | Value | Description | | --- | --- | --- | | data* | expression, variable | data to decode | | charset | text, expression, variable | character set encoding for converting bytes to characters(default: UTF-8) | | returnVariable | expression, variable | name of the variable to be assigned to the return value | ```actionscript authHeader = {Authorization: "Basic dXNlcm5hbWU6cGFzc3dvcmQ="} b64Credentials = splitString(authHeader.Authorization, "/\s+/") textCredentials = decodeBase64ToString(b64Credentials[2], "UTF-8") splitCredentials = splitString(textCredentials, ":", 2) username = splitCredentials[0] password = splitCredentials[1] ``` ### decodeHexToBytes Decode Ascii Hex encoded data to a byte array. | Property | Value | Description | | --- | --- | --- | | data* | expression, variable | data to decode | | returnVariable | expression, variable | name of the variable to be assigned to the return value | ```actionscript md5hashBytes = decodeHexToBytes(md5hash) ``` ### decodeHexToString Decode Ascii Hex encoded data to a string. | Property | Value | Description | | --- | --- | --- | | data* | expression, variable | data to decode | | charset | text, expression, variable | character set encoding for converting bytes to characters(default: UTF-8) | | returnVariable | expression, variable | name of the variable to be assigned to the return value | ```actionscript string = decodeHexToString(hexstring) ``` ### encodeBytesToBase64 Encode a byte array as Base64. | Property | Value | Description | | --- | --- | --- | | data* | expression, variable | data to encode | | breakLines | boolean, expression, variable | break base64 output into lines (default: false) | | returnVariable | expression, variable | name of the variable to be assigned to the return value | ```actionscript ldapRecord = getLDAPRecord(ldapConnection,"cn=jdoe,ou=people,o=data","photo") photoBase64 = encodeBytesToBase64(ldapRecord.photo,true) ``` ### encodeBytesToHex Encode a byte array as Ascii Hex. | Property | Value | Description | | --- | --- | --- | | data* | expression, variable | data to encode | | returnVariable | expression, variable | name of the variable to be assigned to the return value | ```actionscript md5hash = encodeBytesToHex(md5hashBytes) ``` ### encodeStringToBase64 Encode a string as Base64. | Property | Value | Description | | --- | --- | --- | | data* | expression, variable | data to encode | | charset | text, expression, variable | character set encoding for converting characters to bytes(default: UTF-8) | | breakLines | boolean, expression, variable | break base64 output into lines (default: false) | | returnVariable | expression, variable | name of the variable to be assigned to the return value | ```actionscript xml = base64XML = encodeStringToBase64(xml.toXMLString()) setRecordFieldValue(record, "someBase64Field", base64XML) ``` ### encodeStringToHex Encode a string as Ascii Hex. | Property | Value | Description | | --- | --- | --- | | data* | expression, variable | data to encode | | charset | text, expression, variable | character set encoding for converting characters to bytes(default: UTF-8) | | returnVariable | expression, variable | name of the variable to be assigned to the return value | ```actionscript hex = decodeHexToString(string) ```