很多HTTP接口在传参时,需要先对接口的参数进行数据签名加密
如以下POST接口

http://localhost:8080/pinter/com/userInfo

参数为
{"phoneNum":"123434","optCode":"testfan","timestamp":"1211212","sign":"fdsfdsaafsasfas"}

其中,sign字段是按照特定算法进行加密后的数据
本接口的签名算法为
sign=Md5(phoneNum+ optCode+ timestamp)

签名过程中涉及到的C语言函数
字符串拼接
char str[50];
strcat(str,"testfan");
保存当前时间戳:web_save_timestamp_param("tStamp", LAST );

注意 引入 md5.h 文件进行算法解密

 Action()
{
//定义 字符串类型
char cat[]; web_reg_find("Search=Body",
"SaveCount=find_cnt",
"Text=code\":\"0\"",
LAST); web_save_timestamp_param("tStamp", LAST ); //拼接 在一起
strcat(cat, lr_eval_string("135{phoneNum}"));
strcat(cat, "testfan");
strcat(cat, lr_eval_string("{tStamp}")); //CMd5 是调用的 MD5.h 这个文件中的 函数进行md5 解码的
lr_save_string(CMd5(cat), "singMd5"); lr_output_message("==============================%s",CMd5(cat)); web_add_header("Content-type", "application/json"); lr_start_transaction("singmd5"); web_custom_request("post", "Method=POST", "URL=http://localhost:8080/pinter/com/userInfo", "Body={\"phoneNum\":\"135{phoneNum}\",\"optCode\":\"testfan\",\"timestamp\":\"{tStamp}\",\"sign\":\"{singMd5}\"}", "TargetFrame=", LAST ); if(atoi(lr_eval_string("{find_cnt}")) > ){
lr_end_transaction("singmd5", LR_PASS); }else{ lr_end_transaction("singmd5", LR_FAIL); } return ;
}

运行日志如下:

 Virtual User Script started at : -- ::
Starting action vuser_init.
Web Turbo Replay of LoadRunner 11.0. for WINXP; build (Aug ::) [MsgId: MMSG-]
Run Mode: HTML [MsgId: MMSG-]
Run-Time Settings file: "C:\test_huzhenyu\Script\singn\\default.cfg" [MsgId: MMSG-]
Ending action vuser_init.
Running Vuser...
Starting iteration .
Starting action Action.
Action.c(): Registering web_reg_find was successful [MsgId: MMSG-]
Action.c(): Notify: Saving Parameter "tStamp = 1552736236160".
Action.c(): web_save_timestamp_param("web_save_timestamp_param") was successful [MsgId: MMSG-]
Action.c(): Notify: Parameter Substitution: parameter "phoneNum" = ""
Action.c(): Notify: Parameter Substitution: parameter "tStamp" = ""
Action.c(): Notify: Saving Parameter "singMd5 = b7f1b1f74de61497d65fd0027b8166fc".
Action.c(): ==============================b7f1b1f74de61497d65fd0027b8166fc
Action.c(): Warning -: The header being added may cause unpredictable results when applied to all ensuing URLs. It is added anyway [MsgId: MWAR-]
Action.c(): web_add_header("Content-type") highest severity level was "warning" [MsgId: MMSG-]
Action.c(): Notify: Transaction "singmd5" started.
Action.c(): Notify: Parameter Substitution: parameter "phoneNum" = ""
Action.c(): Notify: Parameter Substitution: parameter "tStamp" = ""
Action.c(): Notify: Parameter Substitution: parameter "singMd5" = "b7f1b1f74de61497d65fd0027b8166fc"
Action.c(): t=1018ms: -byte response headers for "http://localhost:8080/pinter/com/userInfo" (RelFrameId=, Internal ID=)
Action.c(): HTTP/1.1 \r\n
Action.c(): Content-Type: application/json;charset=UTF-\r\n
Action.c(): Transfer-Encoding: chunked\r\n
Action.c(): Date: Sat, Mar :: GMT\r\n
Action.c(): \r\n
Action.c(): t=1061ms: -byte chunked response overhead for "http://localhost:8080/pinter/com/userInfo" (RelFrameId=, Internal ID=)
Action.c(): 12a\r\n
Action.c(): t=1068ms: -byte chunked response overhead for "http://localhost:8080/pinter/com/userInfo" (RelFrameId=, Internal ID=)
Action.c(): \r\n
Action.c(): t=1077ms: -byte chunked response body for "http://localhost:8080/pinter/com/userInfo" (RelFrameId=, Internal ID=)
Action.c(): {"code":"","message":"success","data":{"id":,"userName":"鎬ц兘娴嬭瘯","password":nul
Action.c(): l,"age":,"gender":,"phoneNum":"","email":"beihe@testfan.com","address":"鍖椾
Action.c(): 含甯傛槍骞冲尯绉戞槦瑗胯矾106鍙烽櫌锛堝浗椋庣編鍞愯姳鍥患鍚堟ゼ锛\x893鍙锋ゼ1111","creat
Action.c(): eTime":null,"updateTime":null}}
Action.c(): HTML parsing not performed for Content-Type "application/json" ("ParseHtmlContentType" Run-Time Setting is "TEXT"). URL="http://localhost:8080/pinter/com/userInfo" [MsgId: MMSG-]
Action.c(): t=1122ms: -byte chunked response overhead for "http://localhost:8080/pinter/com/userInfo" (RelFrameId=, Internal ID=)
Action.c(): \r\n
Action.c(): \r\n
Action.c(): Registered web_reg_find successful for "Text=code":""" (count=1) [MsgId: MMSG-26364]
Action.c(): Notify: Saving Parameter "find_cnt = 1".
Action.c(): web_custom_request("post") was successful, body bytes, header bytes, chunking overhead bytes [MsgId: MMSG-]
Action.c(): Notify: Parameter Substitution: parameter "find_cnt" = ""
Action.c(): Notify: Transaction "singmd5" ended with "Pass" status (Duration: 0.7485 Wasted Time: 0.4988).
Ending action Action.
Ending iteration .
Ending Vuser...
Starting action vuser_end.
Ending action vuser_end.
Vuser Terminated.

MD5接口解密操作_接口签名校验的更多相关文章

  1. 接口鉴权之sign签名校验与JWT验证

    需求描述: 项目里的几个Webapi接口需要进行鉴权,同接口可被小程序或网页调用,小程序里没有用户登录的概念,网页里有用户登录的概念,对于调用方来源是小程序的情况下进行放权,其他情况下需要有身份验证. ...

  2. Java修炼——接口详解_接口的特征_使用接口的意义

    接口中可以包含的内容: 抽象法和非抽象方法(jdk1.8,必须使用default的关键字),属性(public static final)常量. 接口和类的关系 1.(继承了接口)类必须去实现接口中的 ...

  3. MD5进行解密操作

    package com.dyy.test; import java.security.MessageDigest; public class TestMD5Util { /*** * MD5加码 生成 ...

  4. JMeter接口测试-接口签名校验

    前言 很多HTTP接口在传参时,需要先对接口的参数进行数据签名加密 如pinter项目的中的签名接口 http://localhost:8080/pinter/com/userInfo 参数为: {& ...

  5. API接口签名校验(C#版)

    我们在提供API服务的时候,为了防止数据传输过程被篡改,通常的做法是对传输的内容进行摘要签名,把签名串同参数一起请求API,API服务接收到请求后以同样的方式生成签名串,然后进行对比,如果签名串不一致 ...

  6. 多测师讲解自动化测试 _接口面试题(001)_高级讲师肖sir

    1.为什么要做接口测试(必要性)1.可以发现很多在页面上操作发现不了的bug2.检查系统的异常处理能力3.检查系统的安全性.稳定性4.前端随便变,接口测好了,后端不用变5.可以测试并发情况,一个账号, ...

  7. C#_接口与抽象类

    .Net提供了接口,这个不同于Class或者Struct的类型定义.接口有些情况,看似和抽象类一样,因此有些人认为在.Net可以完全用接口来替换抽象类.其实不然,接口和抽象类各有长处和缺陷,因此往往在 ...

  8. java-继承进阶_抽象类_接口

    概要图 一, 继承的进阶 1.1,成员变量 重点明确原理. 特殊情况: 子父类中定义了一模一样的成员变量. 都存在于子类对象中. 如何在子类中直接访问同名的父类中的变量呢? 通过关键字 super来完 ...

  9. 【linux草鞋应用编程系列】_1_ 开篇_系统调用IO接口与标准IO接口

    最近学习linux系统下的应用编程,参考书籍是那本称为神书的<Unix环境高级编程>,个人感觉神书不是写给草鞋看的,而是 写给大神看的,如果没有一定的基础那么看这本书可能会感到有些头重脚轻 ...

随机推荐

  1. 使用CSV Data Set Config实现参数化登录

    在使用Jemeter做压力测试的时候,往往需要参数化用户名,密码以到达到多用户使用不同的用户名密码登录的目的.这个时候我们就可以使用CSV Data Set Config实现参数化登录: 首先通过Te ...

  2. Java关于NIO类的详解

    一.IO与NIO的区别: 前提我们先说一说java IO: Java中使用IO(输入输出)来读取和写入,读写设备上的数据.硬盘文件.内存.键盘......,根据数据的走向可分为输入流和输出流,这个走向 ...

  3. button onclick实现跳转的常用方法

    1.onclick="javascript:window.location.href='aa.htm' " 2.onclick="location='URL' " ...

  4. yii学习笔记(6),连接数据库,创建活动记录类

    创建数据库用于测试 配置数据库连接 打开yii的配置文件目录下的数据库配置文件config/db.php <?php return [ 'class' => 'yii\db\Connect ...

  5. C#的哈希表Hashtable同步方法

    在多线程环境的操作中对Hashtable进行操作需要进行同步控制,有两种方法,一种是由.Net自动控制:一种是在代码中自己控制. 1.使用Hashtable.Synchronized进行同步 Hash ...

  6. Python爬虫系列 - 初探:爬取新闻推送

    Get发送内容格式 Get方式主要需要发送headers.url.cookies.params等部分的内容. t = requests.get(url, headers = header, param ...

  7. easyui设置行的背景色

    var arr = new Array(3000082, 3000095); self.itemGrid.datagrid({ rowStyler: function (index, row) { f ...

  8. Solr与Lucene的区别

    Lucene是一个优秀的开源搜索库,Solr是在Lucene上封装的完善的搜索引擎.通俗地说,如果Solr是汽车,那么Lucene就是发动机,没有发动机,汽车就没法运转,但对于用户来说只可开车,不能开 ...

  9. 20145209刘一阳《网络对抗》Exp6信息搜集与漏洞扫描

    20145209刘一阳<网络对抗>Exp6信息搜集与漏洞扫描 实践内容 信息搜集和漏洞扫描 信息搜集 whois查询 用whois查询博客园网站的域名注册信息可以得到注册人的名字.城市等信 ...

  10. 武汉Uber优步司机奖励政策(1月11日~1月17日)

    滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...