Forum Discussion

Philip_Baird's avatar
Community Expert
11 years ago

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?



Phil Baird

9 Replies