Ask a Question

Encrypt/Decrypt Base64 string in TestComplete

New Contributor

Encrypt/Decrypt Base64 string in TestComplete



I'm in need of decrypting a Base64 string in a Testcomplete script. The value is coming from a datafile. Is it possible to use a javascript method like atob() or btoa(), within testcomplete for this purpose? Or is there any other option?




Occasional Contributor

If you have dotNet extension installed, you could try something like


var encodedText = dotNET.System.Convert.ToBase64String("Hello World"); 

Hi @rraghvani, thanks for the suggestion. It seemed working. However, I wanted to convert using 'FromBase64String', which gave me the byte array of the converted string. And had troubles converting the byte array to the string. At the and created following function to invoke a PowerShell command. That did the trick for me. 


function b64ToString (str){

var ps = dotNET.System_Management_Automation.PowerShell.Create();

ps.AddScript( "[Text.Encoding]::Utf8.GetString([Convert]::FromBase64String('"+str+"')) | Out-String");

var results = ps.Invoke();

for (i = 0; i < results.Count; i++)
convertedString = results.Item(i).ImmediateBaseObject;


return convertedString;



Showing results for 
Search instead for 
Did you mean: