Convert.ToBase64(Convert)

Converts an unencrypted string into a base 64 encrypted string.

Applies To

Description

Converts an unencrypted string into a base 64 encrypted string. This will be especially useful when passing data to and from an API.

Properties and Methods

None

Available

The .ToBase64(Convert) method is available in:

  • 16.05.081

  • 16.06.032

  • 16.07.005

  • 17.00.002

  • All newer builds

Type

String

Syntax

Convert.ToBase64(Convert);

Parameters

Parameter

Required

Description

String Yes An unencrypted string

Example

var lcTest = 'imorris:123';

var lcVerifiedB64Value = 'aW1vcnJpczoxMjM=';

var lcResult = Convert.ToBase64(lcTest);

Event.Form.YesNo('Encoded: ' + lcResult + '\r\n Verified Value: ' + lcVerifiedB64Value + '\r\n Match: ' + (lcResult === lcVerifiedB64Value));

lcResult = Convert.FromBase64(lcResult);

 

Event.Form.YesNo('Decoded: ' + lcResult + '\r\n Original Value: ' + lcTest + '\r\n Match: ' + (lcTest === lcResult));

/* First Expected System Prompt Display:

Encoded: aW1vcnJpczoxMjM=

Verified Value: aW1vcnJpczoxMjM=

Match: true

 

Second Expected System Prompt Display:

Decoded: imorris:123

Original Value: imorris:123

Match: true

*/