当前位置:网站首页>Jmeter secondary development to realize rsa encryption
Jmeter secondary development to realize rsa encryption
2022-08-03 01:03:00 【Rejoice in the testing world】
jmeterFunctions assistant provides a large number of,像 counter、digest、random、split、strLen,These functions in the interface test、Performance testing is used in great quantities,But everyone in the practical work,A variety of test requirements of different,导致jmeterBuilt-in or extensions provide us all the function can't meet,This time we can diy,对JMeter进行二次开发.

Then I takeaesEncryption to illustrate how to realizeJMeter二次开发.
首先需要将jmeter的core、functions两个jar包导入到项目工程中.
这两个jar包在jmeter的lib\ext目录下,Integrity of the package name as shown below:
ApacheJMeter_core.jar
ApacheJMeter_functions.jar
接下来定义类,类名Rsa0706,继承抽象类AbstractFunction,
实现其中的4个方法execute()、setParameters()、getReferenceKey()、getArgumentDesc(),具体代码如下所示:

1、getReferenceKey方法实现
getReferenceKey()The name of the method is used to return a custom function,The following code defines a class member variablekey,值为字符串“__rsa”,key The value of this variable asgetReferenceKey()方法的返回值.

2,getArgumentDesc方法实现
getArgumentDesc()用来定义jmeterDescription of each parameter information,
Let's be encapsulatedjmeter的rsaEncryption function has two into the,Respectively is encrypted string(即明文),As well as the public key encryption,如下代码所示,定义类成员变量desc,To save the description of the two into the reference information as the variable,作为getArgumentDesc()方法的返回值.

3,setParameters方法实现
setParameters()方法用于获取JMeterFunction of the parameter values,咱们rsaEncryption need two into the reference,Are clear、公钥,参数个数是2,在setParameters()Methods need to check into the maximum number of arguments、The minimum value is2,Then the parameter collectionCollectionInto the array toObject数组变量values中,And define a class member variableMAX_PARA_COUNT、MIX_PARA_COUNT、plaintextCV、publicKeyCV,Are stored the biggest variable number、The minimum number of variables、明文、公钥.

4,execute方法实现
方法execute()里定义的是JmeterThe main logic code a custom function,Let's put in hereaesThe business logic of the encryption method to realize


Then debugging good project intojar包,拷贝到jmeter的lib\ext目录下.
启动jmeter,可以在jmeterThe function of assistant interface to see,自定义的__rsa函数,如下截图所示.

例如公钥:
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQClvArPDQsHpny6fNi1dVyjwz6GTtuKZ5hy8qb62ndCiGXgH5d9WSPeH6RIA14SMGwFwXAd2btntdmvs0CXtSDRP7cXiomEDgBSoDyNbjblQWFKKresjHuxka37rKUgwsDmsaCBE75nUVghJnqmZBhmZ/m9USdsfBbKPogpuVrNtwIDAQAB
1234567890This string of clear afterrsaPublic-key encryption after,结果如下截图所示

b9U55CVXTK+LOWuJPscL/074YtDNTr7fQCitxr73Sq9y4/P7q+TY+lm/L5QpTI8cpnJc6Q6V2I6WSUHFsSFmibwsAacdlIWbvjGxIy2z7F+Y0Ymj32GsFpbi85ea4GFhvrvzYDKp1IRUqo4oCWSwx6zV43gD3NFQHaoKKaU91As=


Then debugging good project intojar包,拷贝到jmeter的lib\ext目录下.
启动jmeter,可以在jmeterThe function of assistant interface to see,自定义的__rsa函数,如下截图所示.

例如公钥:
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQClvArPDQsHpny6fNi1dVyjwz6GTtuKZ5hy8qb62ndCiGXgH5d9WSPeH6RIA14SMGwFwXAd2btntdmvs0CXtSDRP7cXiomEDgBSoDyNbjblQWFKKresjHuxka37rKUgwsDmsaCBE75nUVghJnqmZBhmZ/m9USdsfBbKPogpuVrNtwIDAQAB
1234567890This string of clear afterrsaPublic-key encryption after,结果如下截图所示

b9U55CVXTK+LOWuJPscL/074YtDNTr7fQCitxr73Sq9y4/P7q+TY+lm/L5QpTI8cpnJc6Q6V2I6WSUHFsSFmibwsAacdlIWbvjGxIy2z7F+Y0Ymj32GsFpbi85ea4GFhvrvzYDKp1IRUqo4oCWSwx6zV43gD3NFQHaoKKaU91As=
最后: 可以在公众号:伤心的辣条 ! 自行领取一份216页软件测试工程师面试宝典文档资料【免费的】.以及相对应的视频学习教程免费分享!,其中包括了有基础知识、Linux必备、Shell、互联网程序原理、Mysql数据库、抓包工具专题、接口测试工具、测试进阶-Python编程、Web自动化测试、APP自动化测试、接口自动化测试、测试高级持续集成、测试架构开发测试框架、性能测试、安全测试等.
现在我邀请你进入我们的软件测试学习交流群:【746506216】,备注“入群”, 大家可以一起探讨交流软件测试,共同学习软件测试技术、面试等软件测试方方面面,还会有免费直播课,收获更多测试技巧,我们一起进阶Python自动化测试/测试开发,走向高薪之路.
喜欢软件测试的小伙伴们,如果我的博客对你有帮助、如果你喜欢我的博客内容,请 “点赞” “评论” “收藏” 一 键三连哦!
软件测试工程师自学教程:
这才是2022最精细的自动化测试自学教程,我把它刷了无数遍才上岸字节跳动,做到涨薪20K【值得自学软件测试的人刷】
软件测试工程师月薪2W以上薪资必学技能 — Python接口自动化框架封装.
美团面试真题_高级测试25K岗位面试 — 软件测试人都应该看看
软件测试必会_Jmeter大厂实战 — 仅6步可实现接口自动化测试

边栏推荐
- qt静态编译出现Project ERROR: Library ‘odbc‘ is not defined
- Token、Redis实现单点登录
- Sentinel vs Hystrix 限流对比,到底怎么选?
- 谷粒商城-day13-es和商品上架
- SSM integration steps (emphasis)
- Command line startup FAQs and solutions
- 若依集成minio实现分布式文件存储
- 你离「TDengine 开发者大会」只差一条 SQL 语句!
- 学习基因富集工具DAVID(3)
- The interviewer asked me: delete library, in addition to run do?
猜你喜欢
随机推荐
七夕到了——属于程序员的浪漫
mysql查询表中重复记录
无代码开发平台数据ID入门教程
kubernetes pod podsecurityPolicies(PSP)
MySQL 用id分库使用name查询
IDO预售代币合约系统开发技术说明及源码分析
第十章 时序与延迟
[TypeScript] Deep Learning of TypeScript Classes (Part 1)
在软件测试行业近20年的我,再来和大家谈谈今日的软件测试
CTF命令执行题目解题思路
雷克萨斯lm的安全性如何?
[论文总结] 深度学习在农业领域应用论文笔记10
RuoYi-App Startup Tutorial
Yocto系列讲解[实战篇]85 - 制作ubi镜像和自动挂载ubifs文件系统
H.265视频流媒体播放器EasyPlayer.js集成时出现“SourceBuffer ”报错,该如何解决?
「X」to「Earn」:赛道现状与破局思路
反弹shell原理与实现
PHP实现登录失败三次需要输入验证码需求
谷粒商城-day14-商城业务与压力测试
Task 4 Machine Learning Library Scikit-learn

![Yocto系列讲解[实战篇]85 - 制作ubi镜像和自动挂载ubifs文件系统](/img/96/beb34ce07f1e4c0fe932359e42e5c6.png)








