Philip_Baird
11 years agoCommunity Expert
Base64 encoded string
Hi, as part of a XHR web service call I am testing, I am required to send basic Authorization in the header encoded as Base64.
I couldn't find a way to do this from a Test Complete object so came up with the following using the dotNET object:
function getEncodedCredentials( userName, password ) {
var textBytes = dotNET.System_Text.Encoding.UTF8.GetBytes_2( userName + ":" + password );
var encodedText = dotNET.System.Convert.ToBase64String( textBytes );
return encodedText;
}
which is used such as:
Log.Message( getEncodedCredentials( "fred", "fl1ntst0ne" ) );
My question is this, is their another way to do this in Test Complete that does not require a call to the CLR Bridge?
Regards,
Phil Baird
- Hi Phil,
I used .Net-based approach in several projects and it worked fine.
However, the following request http://www.google.com/search?q=base64+encode+string+jscript+vbscript returned quite a few results the first of which http://stackoverflow.com/questions/496751/base64-encode-string-in-vbscript looks quite interesting (though I did not verified what people have talked there about).