Back to Blog

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:

Action()
{
char *decodedMessage;
char *sourceMessage;
char *encodedMessage;
char *ParameterToFunction;

sourceMessage="demande.demandeur:123456789";
lr_load_dll("micsocket.dll");
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

ParameterToFunction=util_base64decode(encodedMessage);

//lr_message( "\n %s ",ParameterToFunction);
//lr_save_string saves a C language string in LR parameter
// In this case, it is a flex function

//<body class=\"string\">{PARAM}</body>"

lr_save_string(ParameterToFunction, "PARAM");
lr_output_message("Param = %s", lr_eval_string("{PARAM}"));
return 0;
}
Back to Blog