当前位置: 首页 > 编程日记 > 正文

Loadrunner进行md5加密方法

本文主要介绍使用Loadrunner进行字符串md5加密的方法。

使用Loadrunner进行md5比较简单,首先是加载md5.h头文件,后使用头文件中的加密函数即可。

1. md5.h头文件内容如下

#ifndef MD5_H
#define MD5_H
#ifdef __alpha
typedef unsigned int uint32;
#else
typedef unsigned long uint32;
#endif
struct MD5Context {uint32 buf[4];uint32 bits[2];unsigned char in[64];
};
extern void MD5Init();
extern void MD5Update();
extern void MD5Final();
extern void MD5Transform();
typedef struct MD5Context MD5_CTX;
#endif
#ifdef sgi
#define HIGHFIRST
#endif
#ifdef sun
#define HIGHFIRST
#endif
#ifndef HIGHFIRST
#define byteReverse(buf, len) /* Nothing */
#else
void byteReverse(buf, longs)unsigned char *buf; unsigned longs;
{uint32 t;do {t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 |((unsigned) buf[1] << 8 | buf[0]);*(uint32 *) buf = t;buf += 4;} while (--longs);
}
#endif
void MD5Init(ctx)struct MD5Context *ctx;
{ctx->buf[0] = 0x67452301;ctx->buf[1] = 0xefcdab89;ctx->buf[2] = 0x98badcfe;ctx->buf[3] = 0x10325476;ctx->bits[0] = 0;ctx->bits[1] = 0;
}
void MD5Update(ctx, buf, len) struct MD5Context *ctx; unsigned char *buf; unsigned len;
{uint32 t;t = ctx->bits[0];if ((ctx->bits[0] = t + ((uint32) len << 3)) < t)ctx->bits[1]++;ctx->bits[1] += len >> 29;t = (t >> 3) & 0x3f;if (t) {unsigned char *p = (unsigned char *) ctx->in + t;t = 64 - t;if (len < t) {memcpy(p, buf, len);return;}memcpy(p, buf, t);byteReverse(ctx->in, 16);MD5Transform(ctx->buf, (uint32 *) ctx->in);buf += t;len -= t;}while (len >= 64) {memcpy(ctx->in, buf, 64);byteReverse(ctx->in, 16);MD5Transform(ctx->buf, (uint32 *) ctx->in);buf += 64;len -= 64;}memcpy(ctx->in, buf, len);
}
void MD5Final(digest, ctx)unsigned char digest[16]; struct MD5Context *ctx;
{unsigned count;unsigned char *p;count = (ctx->bits[0] >> 3) & 0x3F;p = ctx->in + count;*p++ = 0x80;count = 64 - 1 - count;if (count < 8) {memset(p, 0, count);byteReverse(ctx->in, 16);MD5Transform(ctx->buf, (uint32 *) ctx->in);memset(ctx->in, 0, 56);} else {memset(p, 0, count - 8);}byteReverse(ctx->in, 14);((uint32 *) ctx->in)[14] = ctx->bits[0];((uint32 *) ctx->in)[15] = ctx->bits[1];MD5Transform(ctx->buf, (uint32 *) ctx->in);byteReverse((unsigned char *) ctx->buf, 4);memcpy(digest, ctx->buf, 16);memset(ctx, 0, sizeof(ctx));
}
#define F1(x, y, z) (z ^ (x & (y ^ z)))
#define F2(x, y, z) F1(z, x, y)
#define F3(x, y, z) (x ^ y ^ z)
#define F4(x, y, z) (y ^ (x | ~z))
#define MD5STEP(f, w, x, y, z, data, s) ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
void MD5Transform(buf, in)uint32 buf[4]; uint32 in[16];
{register uint32 a, b, c, d;a = buf[0];b = buf[1];c = buf[2];d = buf[3];MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);buf[0] += a;buf[1] += b;buf[2] += c;buf[3] += d;
}
void GetMd5FromString(const char* s,char* resStr)
{struct MD5Context md5c;unsigned char ss[16];char subStr[3];int i;MD5Init( &md5c );MD5Update( &md5c, s, strlen(s) );MD5Final( ss, &md5c );strcpy(resStr,"");for( i=0; i<16; i++ ){sprintf(subStr, "%02x", ss[i] );itoa(ss[i],subStr,16);if (strlen(subStr)==1) {strcat(resStr,"0");}strcat(resStr,subStr);}strcat(resStr,"\0");
}

2. Loadrunner测试代码如下

#include "lrs.h"
#include "md5.h"Action()
{char *s="12345abc";
char *dest=(char *) malloc(10*1024);GetMd5FromString(s,dest);
lr_message(dest);return 0;
}

运行截图如下:

使用Loadrunner进行MD5加密示例

使用Loadrunner进行MD5加密示例

转载于:https://www.cnblogs.com/shengs/p/3790047.html

相关文章:

6 Java Shell排序

希尔排序是先将整个待排序的记录序列分割成为若干子序列分别进行直接插入排序&#xff0c;待整个序列中的记录“基本有序”时&#xff0c;再对全体记录进行依次直接插入排序。 1、基本思想 将待排序数组按照步长gap进行分组&#xff0c;然后将每组的元素利用直接插入排序的方法…

如何向非技术人员解释“稀疏傅里叶变换”算法?

【伯乐在线导读】&#xff1a;这个问题来自 Quora&#xff0c;下面是来自 Tanooj Luthra 的回复。 让我们来演奏一架想象中的钢琴。 钢琴的每个琴键都对应一个特定频率的声音。例如&#xff0c;一个比较有名的频率是国际标准音A&#xff08;440赫兹&#xff09;。当有琴键按下时…

N皇后摆放问题

Description 在N*N的方格棋盘放置了N个皇后&#xff0c;使得它们不相互攻击&#xff08;即任意2个皇后不允许处在同一排&#xff0c;同一列&#xff0c;也不允许处在与棋盘边框成45角的斜线上。你的任务是&#xff0c;对于给定的N&#xff0c;求出有多少种合法的放置方法。 Inp…

java线程的优先级是数字越大优先级越高_《深入理解Java虚拟机》5分钟速成:12章(Java内存模型与线程)...

第12章 Java内存模型与线程前言&#xff1a;1、物理机如何处理并发问题&#xff1f;2、什么是Java内存模型&#xff1f;3、原子性、可见性、有序性的具体含义和应用实现&#xff1f;4、volatile 关键字特性&#xff1f;5、基于volatile变量的运算在并发下是否是线程安全的&…

动软代码生成V2.74模版简介

最近发现很多人用动软代码生成&#xff0c;确实方便&#xff0c;有些经验记录下&#xff0c;以后查看回顾。 ..\Maticsoft\Codematic2\Template\TemplateFile 为模板文件夹&#xff0c;直接在目录下新建文件夹【我的自定义模版】,有个【模版示例.cmt】也直接复制到自定义文件下…

《少年先疯队》第九次团队作业:Beta冲刺第二天

2.1 今日完成任务情况 姚玉婷&#xff1a;房间管理功能测试文档的编写马丽莎&#xff1a;酒店系统中商品管理功能的完善张 琼&#xff1a;商品管理功能的测试孙苗坤&#xff1a;商品管理功能的测试2.2 明天任务安排 姚玉婷&#xff1a;酒店系统中剩余功能的完善马丽莎&#x…

傅里叶变换的参考文档

https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/ http://blog.jobbole.com/70549/

取消ssh密钥文件登录_Xshell密钥登入,增加安全

1.点击Xshell菜单栏的工具&#xff0c;选择新建用户密钥生成向导&#xff0c;进行密钥对生成操作。2.这个时候&#xff0c;你已经有了一对密钥&#xff0c;需要开始设定服务器的配置&#xff0c;启用密钥认证登录&#xff0c;同时为了系统安全着想&#xff0c;关闭密码认证的方…

20150726 填坑日记

三中内填坑&#xff1a; 1. 组合数递推什么的 C(m,n)C(m,n-1)C(m-1,n-1)。填了个大坑&#xff0c;以前没认真听课QAQ 2. 裸题过河卒 3. 缺角正方形摆放车统计&#xff0c;分上下部分&#xff0c;枚举上部分放几个即可&#xff0c;O(n) 4. 3d立体图统计表面积&#xff1a;先把上…

Word 2003文件保存和另存为操作是否熟练掌握的有关测试

提出问题本文内容不仅适用于Word&#xff0c;对于其他的文档&#xff08;文字、图形、动画、声音等&#xff09;编辑软件基本通用。对于操作上述各种编辑软件时&#xff0c;大家都应该注意到&#xff0c;我们第一次保存文件时系统出现的是“另存为”对话框。此后&#xff0c;再…

kdress学习

这两天看了一本书叫《linux二进制分析》&#xff0c;这里面提到的一个小工具kdress&#xff0c;这里分析一下 源码在&#xff1a;https://github.com/elfmaster/kdress kdress介绍 /boot目录下有一个vmlinux的文件&#xff0c;这是一个经过压缩的linux内核&#xff0c;不过缺少…

什么是DCI? 它有什么用?

当你学习LTE的物理帧(physicalframe)结构时,你肯定会有所体会&#xff1a;”靠&#xff0c;怎么这么复杂啊”.物理帧结构是时域 (Time Domain)、频域(Frequency Domain)和调制方式&#xff08;modulation scheme&#xff09;的组合。 你可能会有疑问&#xff1a;”接收方怎么知…

判断小数是否相等_四年级上册数学填空+计算+判断易错题整理练习,收藏练一练!...

四年级数学易错题练习一、填空题1、1.250.8表示( )。2、去掉0.25的小数点&#xff0c;就是把这个数扩大( )&#xff1b;把50.4的小数点向左移动两位&#xff0c;就是把它缩小到原来的( )。3、两个因数相乘, 一个因数扩大10倍&#xff0c;另一个因数扩大…

jquery checkbox勾选/取消勾选的诡异问题

$("input[idsubmit2]").click(function() {   $("[idpostage2]").prop("checked", true); }); $("input[idsubmit3]").click(function() {   $("[idpostage2]").prop("checked", false); }); 解决办法&#x…

C#_uploadify_mvc_version

jQuery Uploadify在ASP.NET MVC3中的使用 1、Uploadify简介 Uploadify是基于jQuery的一种上传插件&#xff0c;支持多文件、带进度条显示上传&#xff0c;在项目开发中常被使用。 Uploadify官方网址&#xff1a;http://www.uploadify.com/ 2、ASP.NET MVC3中的使用Uploadify 搭…

Velocity Engine基础

回到顶部Velocity是一个基于Java的模板引擎,可以通过特定的语法获取在java对象的数据 , 填充到模板中,从而实现界面和java代码的分离!Velocity Template Language (VTL) , 是Velocity 中提供的一种模版语言 , 旨在提供最简单和最干净的方法来将动态内容合并到网页中。简单来说VTL可以将程序中的动态数展示到网页中注释非解析内容 , 引用和指令。

mysql唯一索引与null

根据NULL的定义,NULL表示的是未知,因此两个NULL比较的结果既不相等,也不不等,结果仍然是未知。根据这个定义,多个NULL值的存在应该不违反唯一约束,所以是合理的,在oracel也是如此。在mysql 的innodb引擎中,是允许在唯一索引的字段中出现多个null值的。有上面的表和数据可以看出,查询多条数据。

矩阵乘法递归求解

给定两个NN的矩阵&#xff0c;求乘积 如下图所示&#xff0c;乘法执行过程如下&#xff1a; 1.矩阵1先拿出一行&#xff0c;矩阵2先拿出一列 2.行与列相乘得到value1 3.行与剩下矩阵2相乘得到value2&#xff08;递归过程&#xff09; 4.剩下矩阵1与列相乘得到value3&#xff08…

What is acceptable cell and suitable cell in LTE?

The difference between acceptable cell and suitable cell in LTE is given below. acceptable cell In a area where UE is not able to find any suitable cell to camp on, it goes for acceptable cell. An “acceptable cell” is a cell on which the UE may camp to o…

appium 控件定位

转自&#xff1a;http://www.2cto.com/kf/201410/340345.html AppiumDriver的各种findElement方法的尝试&#xff0c;尝试的目标应用是SDK自带的Notepad应用。 1. findElementByName 1.1 示例 ?12el driver.findElementByName("Add note");assertThat(el.getText()…

android应用去掉状态栏_Android 显示、隐藏状态栏和导航栏

Android 显示、隐藏状态栏和导航栏控制状态栏显示&#xff0c;Activity的主题中配置全屏属性true控制状态栏显示&#xff0c;在setContentView之前设置全屏的flaggetWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREE…

hdu1305Immediate Decodability(字典树)

这题看是否 这题能A是侥幸&#xff0c;解决的办法是先存一下输入的字符串&#xff0c;进行排序。 Problem DescriptionAn encoding of a set of symbols is said to be immediately decodable if no code for one symbol is the prefix of a code for another symbol. We will …

python isdigit()

isdigit(): Python isdigit() 方法检测字符串是否只由数字组成。如果字符串只包含数字则返回 True 否则返回 False。 实例 以下实例展示了isdigit()方法的实例&#xff1a; #!/usr/bin/python3str "123456"; print (str.isdigit()) str "Runoob example....wo…

Control Channel Element (CCE)

1. CCE是PDCCH的资源单元 (resourceunit)。 A PDCCH is transmitted on one CCE or anaggregation of several consecutive CCEs, where a CCE corresponds to 9 Resource ElementGroups (REGs). In PDCCH transmission, only those REGs are used which are notassigned …

phpstrom+xdebug调试PHP代码

众所周知开发PHP的IDE种类繁多&#xff0c;然而开发PHP并不能像开发其他语言一样&#xff0c;调试PHP代码对诸多新手来说&#xff0c;搭建调试环境就比较麻烦&#xff01;其实哈&#xff0c;我发现NuSphere-phped-16.0很强大&#xff0c;集成了很强大的debug功能&#xff0c;只…

ubuntu 设置开机执行脚本_ubuntu-18.04 设置开机启动脚本

ubuntu-18.04 设置开机启动脚本参阅下列链接ubuntu-18.04不能像ubuntu14一样通过编辑rc.local来设置开机启动脚本&#xff0c;通过下列简单设置后&#xff0c;可以使rc.local重新发挥作用。1、建立rc-local.service文件sudo vi /etc/systemd/system/rc-local.service2、将下列内…

Web Api单元测试写法

例如我们在Web Api项目中有个Controller public class SomeController : ApiController { public HttpResponseMessage Get() { // 一些操作 return Request.CreateResponse(HttpStatusCode.OK&#xff0c; someModel); } }如果你在单元测试中直接调用 SomeController 的Get()方…

数据挖掘深入理解和学习路径

上一篇文章中分享了数据分析的学习全景路径 其中最关键的部分就是数据挖掘&#xff0c;那什么是数据挖掘呢&#xff1f; 数据挖掘就是通过分析采集而来的数据源&#xff0c;从庞大的数据中发现规律&#xff0c;找到宝藏。 一&#xff0c;数据挖掘的基本流程 数据挖掘可分为6个步…

3G重选至4G--基于优先级

3G重选至4G--基于优先级 1. Specification 1.1 Measurementrules 是否需要开启测量 3GPP 25.304 - 5.2.6.1.2aMeasurement rules for inter-frequency and inter-RAT cell reselection when absolutepriorities are used 1.2 Evaluation/ ReselectionCriteria 对测量结…

C#_Socket网络编程实现的简单局域网内即时聊天,发送文件,抖动窗口。

C#_Socket网络编程实现的简单局域网内即时聊天&#xff0c;发送文件&#xff0c;抖动窗口。 最近接触了C#Socket网络编程&#xff0c;试着做了试试(*^__^*) 实现多个客户端和服务端互相发送消息 发送文件抖动窗口功能 服务端&#xff1a; using System; using System.Colle…