LoadRunner Vugen: Encoding and Decoding Base64

HP recently released Knowledge Base article KM00211140 for LoadRunner, dealing with decoding the encoded user name and password in a flex call when recording against HP’s Service Manager Service Request Catalog (SRC). SRC  uses both flex and web to communicate to the back end.  The encoding used is Base64. Their example is good,  and could be used as a starting point for encoding/decoding BASE64 for other applications. To pull this off, you will need to include mic_socket.h in the  Globals.h section of the VUgen script . Then access micsocket.dll in the Action section by using the lr_load_dll function. This dll is the base64 encoding library found in the <Loadrunner>/bin directory. There are two functions available for encoding and decoding (trumpets please):  util_base64encode and util_base64decode. See the example code below:

char *decodedMessage;
char *sourceMessage;
char *encodedMessage;
char *ParameterToFunction;
encodedMessage= util_base64encode(sourceMessage);
lr_message( "Decoded message is:\n %s ",sourceMessage);
lr_message( "Encoded message is:\n %s ",encodedMessage);
//Call util_base64decode function to decode, if needed
//lr_message( "\n %s ",ParameterToFunction);
//lr_save_string saves a C language string in LR parameter
// In this case, it is a flex function
//&lt;body class=\"string\"&gt;{PARAM}&lt;/body&gt;"
lr_save_string(ParameterToFunction, "PARAM");
lr_output_message("Param = %s", lr_eval_string("{PARAM}"));
return 0;

What's Next?

Did you enjoy this article? Help spread the word by sharing:

Join the Northway Navigator Club today and get access to restricted content including our best tips and tricks. Membership is free! You will also receive free email updates by registering.

Engage in the conversation and leave a comment:

Scott Moore

About Scott Moore (153 articles)

With over 20 years of IT experience with various platforms and technologies, Scott has tested some of the largest applications and infrastructures in the world. He is a Certified Instructor and Certified Product Consultant in HP’s LoadRunner and Performance Center products. He currently holds HP certifications for ASE, ASC, and CI. A thought leader in the APM space, he speaks regularly at IT conferences and events

  • Jason Montgomery

    Just curious, why would you encode a string? Isn’t the point to encode and transfer binary data? I’m trying to decode/deflate the body of an http response (which ultimately ends up being the contents of an xml file) but not having any luck within VuGen. It looks like I would have to decode the base64 http response body into something binary, unpack it using gzip, then convert the result to a UTF8 string. All of which I can do within my favorite IDE but using C in VuGen is proving difficult for me.