LoadRunner与encode64加密解密(2)
上一篇 /
下一篇 2016-03-04 15:39:12
/ 个人分类:WEB性能测试
1.在LR新建一个项目,名为test
2.新建一个.h结尾的文件,例如名为“base64.h”,把下面的内容复制到这个文件中:(如果没找到附件,见文章base64.h)。之后把base64.h放置到test项目的根目录下。
1.打开test项目的脚本模式,选中Action,右键“Add Files to Script”
2.打开globals.h,添加头文件Base64.h,如下:
#ifndef _GLOBALS_H
#define _GLOBALS_H
//--------------------------------------------------------------------
// Include Files
#include "lrun.h"
#include "web_api.h"
#include "lrw_custom_body.h"
#include "base64.h" //我们刚刚添加的
//--------------------------------------------------------------------
// Global Variables
#endif // _GLOBALS_H
3.使用的例子如下所示:(放到Action中运行尝试)
Action()
{
int res;
lr_save_string("18774970063","Plain1");
b64_encode_string(lr_eval_string({Plain1}"), "B64str" );//编码
lr_output_message("编码结果: \nNotify:\t%s", lr_eval_string({B64str}") );
b64_decode_string(lr_eval_string({B64str}"), "Plain2" );//解码
lr_output_message("解码结果: \nNotify:\t%s", lr_eval_string("{Plain2}") );
res= strcmp( lr_eval_string("{Plain1}"), lr_eval_string("{Plain2}") );// 校验
if (res == 0) lr_output_message("\nNotify:\t校验通过!");
}
自己尝试下吧!
收藏
举报
TAG:
加密