util.Strings.base64DecodeToHexString

Decodes a base64 encoded string and returns the corresponding hexadecimal string.

Syntax

util.Strings.base64DecodeToHexString(
  base64 STRING
 )
  RETURNS STRING
  1. base64 is the Base64 encoded string.

Usage

The util.Strings.base64DecodeToHexString() method converts the Base64 encoded string passed as parameter to an array of bytes, then it converts the byte array to the hexadecimal representation of this array of bytes, and returns that string.

Tip: After converting the Base64 string to an hexadecimal string, use the util.parseHexString() method to convert bytes of the hexadecimal string to integers.

Example

IMPORT util
MAIN
    DEFINE hexa VARCHAR(50)
    DISPLAY util.Strings.base64DecodeToHexString( "AA==" )
    DISPLAY util.Strings.base64DecodeToHexString( "AAAAAA==" )
    DISPLAY util.Strings.base64DecodeToHexString( "AQ==" )
    DISPLAY util.Strings.base64DecodeToHexString( "//8=" )
    DISPLAY util.Strings.base64DecodeToHexString( "QUJDRA==" )
    LET hexa = util.Strings.base64DecodeToHexString( "QUJDRA==" )
    DISPLAY util.Integer.parseHexString( hexa[1,2] )
    DISPLAY util.Integer.parseHexString( hexa[3,4] )
    DISPLAY util.Integer.parseHexString( hexa[5,6] )
    DISPLAY util.Integer.parseHexString( hexa[7,8] )
END MAIN
Output:
00
00000000
01
ffff
41424344
         65
         66
         67
         68