MD5接口解密操作_接口签名校验
很多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接口解密操作_接口签名校验的更多相关文章
- 接口鉴权之sign签名校验与JWT验证
需求描述: 项目里的几个Webapi接口需要进行鉴权,同接口可被小程序或网页调用,小程序里没有用户登录的概念,网页里有用户登录的概念,对于调用方来源是小程序的情况下进行放权,其他情况下需要有身份验证. ...
- Java修炼——接口详解_接口的特征_使用接口的意义
接口中可以包含的内容: 抽象法和非抽象方法(jdk1.8,必须使用default的关键字),属性(public static final)常量. 接口和类的关系 1.(继承了接口)类必须去实现接口中的 ...
- MD5进行解密操作
package com.dyy.test; import java.security.MessageDigest; public class TestMD5Util { /*** * MD5加码 生成 ...
- JMeter接口测试-接口签名校验
前言 很多HTTP接口在传参时,需要先对接口的参数进行数据签名加密 如pinter项目的中的签名接口 http://localhost:8080/pinter/com/userInfo 参数为: {& ...
- API接口签名校验(C#版)
我们在提供API服务的时候,为了防止数据传输过程被篡改,通常的做法是对传输的内容进行摘要签名,把签名串同参数一起请求API,API服务接收到请求后以同样的方式生成签名串,然后进行对比,如果签名串不一致 ...
- 多测师讲解自动化测试 _接口面试题(001)_高级讲师肖sir
1.为什么要做接口测试(必要性)1.可以发现很多在页面上操作发现不了的bug2.检查系统的异常处理能力3.检查系统的安全性.稳定性4.前端随便变,接口测好了,后端不用变5.可以测试并发情况,一个账号, ...
- C#_接口与抽象类
.Net提供了接口,这个不同于Class或者Struct的类型定义.接口有些情况,看似和抽象类一样,因此有些人认为在.Net可以完全用接口来替换抽象类.其实不然,接口和抽象类各有长处和缺陷,因此往往在 ...
- java-继承进阶_抽象类_接口
概要图 一, 继承的进阶 1.1,成员变量 重点明确原理. 特殊情况: 子父类中定义了一模一样的成员变量. 都存在于子类对象中. 如何在子类中直接访问同名的父类中的变量呢? 通过关键字 super来完 ...
- 【linux草鞋应用编程系列】_1_ 开篇_系统调用IO接口与标准IO接口
最近学习linux系统下的应用编程,参考书籍是那本称为神书的<Unix环境高级编程>,个人感觉神书不是写给草鞋看的,而是 写给大神看的,如果没有一定的基础那么看这本书可能会感到有些头重脚轻 ...
随机推荐
- Android 进价5_自定义广播 通过广播更新ListView的适配器 下载管理
1.在处理下载管理时,服务在后台运行,下载完成后要更新listview列表的按钮,将“下载”改成“打开”这样一个功能. 在Activity里面写一个静态内部类,继承广播.其中属性text_button ...
- 《Inetnet History,Technology and Security》学习笔记
前言 本文为观看Cousera的Michigan<Internet History, Technology and Security>教程的个人学习笔记,包括了每个week的概要和个人感想 ...
- iOS:PrefixHeader / 头文件 / 宏定义(18-03-02更)
宏定义,不一定放在PCH文件,可能放在一个.h文件,再用PCH包含进来. 1.屏幕尺寸 // 屏幕尺寸 #define kSCREEN_WIDTH [UIScreen mainScreen].boun ...
- Swift_错误处理
Swift_错误处理 点击查看源码 //错误处理 func test() { //错误枚举 需ErrorType协议 enum ErrorEnum: Error { case `default` // ...
- kafka topic制定规则
kafka topic的制定,我们要考虑的问题有很多,比如生产环境中用几备份.partition数目多少合适.用几台机器支撑数据量,这些方面如何去考量?笔者根据实际的维护经验,写一些思考,希望大家指正 ...
- 【Django笔记一】windows系统下搭建Django项目
一.环境版本信息: 操作系统:windows10 Django版本:2.0.5 Python版本:3.6.4 二.创建虚拟环境: 1.为什么要创建虚拟环境: 我们要开发一个新的项目,需要一套独立的Py ...
- RAC初体验(环境搭建)
实施阶段: 1.主机配置 2.安装Clusterware 3.安装Oracle Database 4.配置Listener 5.创建ASM 6.创建Database 一.主机配置 1.网络设置 I ...
- 关于css属性calc对于ie的态度
做的一个项目,布局的时候用到了max-height:calc(100% - 15px);在谷歌.火狐浏览器,进行下拉的时候,它的父元素会出现垂直滚动条,但是在IE就不可以. 然后在网上找了找,说在它的 ...
- 移动端利用canvas画布简单实现刮刮乐效果
为了研究canvas一些属性简单实现的一个小效果 代码样式不太规范 随手写的 请问喷 初学者可以看下 css代码 <style> * { margin: 0; padding: 0; } ...
- ckeditor + ckfinder + oss存储
ckeditor 与 ckfinder 的整合方法 网上有很多,这里我也就不说了. (主要是以前整合的现在忘记咋弄的了0.0) 我这里整合后直接使用js代码 <script type=&quo ...