当前位置:网站首页>How JMeter uses MD5 encryption and fingerprint signature on the body
How JMeter uses MD5 encryption and fingerprint signature on the body
2022-07-18 16:39:00 【Ali test Jun】
Preface :
During interface testing , Sometimes you will encounter an interface that needs encryption and decryption , Now I will introduce how to target MD5 Encryption interface test , And for body Fingerprint signature for all parameters
1、 First of all, find the developer to understand the requirements , Know it's a http Type of post request , First, you need to get the timestamp (time), And then put appid、body、accessToken、time Count MD5 Encryption processing generates sign, Then send the parameter to the information header to realize authentication , Use body Parameters for fingerprint signature , Can improve security
2、 What we need to do is ask the developer to get MD5 Encryption function (java Code ), And then through jmeter The preprocessor of BeanShell PreProcessor To deal with , This effect can be achieved
【 The end of the article left a lot of benefits for everyone 】
One 、 add to MD5 encryption jar package
1. First, let the development provide MD5 Encryption method , Type this method as jar package , Then place it in apache-jmeter-4.0\lib\ext Catalog , It's restarting jmeter, such jmeter You can call the encryption method


Two 、 add to BeanShell Sample Preprocessor 、HTTP request
1. add to HTTP request ,- Select thread group , Click on the right , add to 》Sampler》HTTP request

2. add to BeanShell request - Choose HTTP request , Click on the right , add to 》 Preprocessor 》BeanShell PreProcessor

3. The code is as follows , First import introduce jar package , Then define time Variable , Use it directly jmeter Bring their own time Function to get the timestamp ,param That's what I said above body Parameters , hold time、param Variables to put It's Jean HTTP The request header can call it , And then in defining sign Variable , Call the introduced jar Package encryption method , Last in put

import com.course.testng.*; // quote jar package
String time = "${__time(,)}"; // Get the timestamp
String param ="{\"activeId\":\"${activeId}\",\"method\":1,\"userId\":${userId},\"userName\":\" automation \",\"userPhone\":\"${mobile}\",\"userHome\":\"${familyName}\",\"communityId\":${communityId},\"houseId\":${houseId},\"houseName\":\"1\\\\/ Unit one \\\\/103\"}" ;
vars.put("time",time); // Set as jmeter Variable
vars.put("param",param); // Set as jmeter Variable , convenient HTTP Request calling , This only needs to be done in beanshell Maintain a set of parameters , Without repeated maintenance
String sign = Encrypt1.test("1120",param,"${accessToken}",time); // call MD5 Encryption method , Generate sign
vars.put("sign",sign); // Set as jmeter Variable
4.HTTP Request directly in body data call ${param} that will do

5. add to HTTP Header Manager - Choose HTTP request , Click on the right , add to 》 The configuration element 》HTTP Header Manager


3、 ... and 、 Perform the requested
1. Click the start button on the page , You can see that the script executes normally , The response result is normal , This script development is complete , You can call this script directly to test


Four 、 The pit encountered in developing this script
1. Execute script prompt SIGN_ERROR, Finally, check with the development java Encryption code , It is found that there is Chinese in the request parameters , then md5 Failure to specify the encoding type resulted in , Specify the code as UTF-8 that will do


2. Execute script message error, View log tips Error invoking bsh method:eval sourced file: , After investigation , The reason is that there are \\/, It needs more \\ Just escape , As shown below


a key : Learning materials of course, learning is inseparable from materials , Of course, here is also prepared for you 600G Learning materials
Private keywords needed 【000】 Get it for free Note that the keywords are :000
Project practice :

Large e-commerce platform :

Full set of software test automation test teaching video

300G Download tutorial materials 【 Video tutorial +PPT+ Project source code 】

A complete set of software testing automation testing factory has been

python automated testing ++ A complete set of templates + Performance testing


It's said that the iron juice who has paid attention to me for three consecutive years has been promoted, raised and made a fortune !!!!
边栏推荐
- Search - binary sort tree (2)
- The professional standard of the new profession "database operation administrator" was launched and developed
- 工业级知识图谱de构建与应用(三):商品知识融合
- [recognizing cloud Nativity] Chapter 4 cloud network section 4.9.4.2 - Implementation of smart network card
- Postgresql-14.4-源码阅读02-ReadBuffer_common-后续再更新此篇-看的头大
- LeetCode腾讯精选练习50题-059.螺旋矩阵II
- LeetCode腾讯精选练习50题-054.螺旋矩阵
- AP统计学
- 18、文本处理工具-grep
- 英特尔 x Datawhale联合认证发布!
猜你喜欢

实现团队工作效率与质量共赢,这款办公协同工具真够用!

可爱的图像分类——《CNN模型中常见的flops到底是什么》一文通解

新职业“数据库运行管理员”职业标准启动开发

Best practice path for problem solving
![[sharing] layer 2 switching and layer 3 switching forwarding](/img/d0/6bf5c158d5194968d298304517f44d.png)
[sharing] layer 2 switching and layer 3 switching forwarding

学习笔记——直流电机调速器

Intel x datawhale joint certification release!

The latest version 0.3 of Infini console, which has been waiting for a long time, is officially released!

各国程序员薪资水平,咱有点惨...

Is the PMP certificate useful?
随机推荐
[Gu Yue 21 lecture] ROS introduction series (3) -- programming implementation of client and server + programming implementation of custom service data
第五人格PC端下载以及解决打不开问题
Halcon distance calculation
Exceptions to the administrative punishment law
Redis基础课程讲义
5 data packets and LSA information of OSPF
【TensorFlow2.9】泰坦尼克号生存预测—结构化数据建模流程
JVM架构解析
图像处理之数据增强
Uncaught Error: Rendered fewer hooks than expected. This may be caused by an accidental early return
结构思考力
Mysql启动选项和配置文件
【VSCode】SyntaxError: Cannot use import statement outside a module
@ConditionalOnProperty的简单理解与使用
[today's little go is going to throw away the garbage (3)]
UE4蓝图学习篇(六)--Branch、Switch、FilpFlop、Sequence
想通讯?谈钱多俗,谈ProtoBuf
MATLAB数字图像处理 实验二:单像素空域图像增强
数据库与开源的未来
OneFlow源码一览:GDB编译调试