Roshantha
3 years agoNew Contributor
Encrypt/Decrypt Base64 string in TestComplete
Hi, 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 f...
- 3 years ago
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;}