当前位置:网站首页>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步可实现接口自动化测试
边栏推荐
猜你喜欢
随机推荐
无代码开发平台数据ID入门教程
【TypeScript】深入学习TypeScript模块化
MDL 内存描述符链表
ML之PDP:基于titanic泰坦尼克是否获救二分类预测数据集利用PDP部分依赖图对RF随机森林和LightGBM模型实现可解释性案例
[TypeScript] Deep Learning of TypeScript Classes (Part 1)
If the watermark according to how to realize the function
Word2Vec词向量训练、使用及可视化操作
You and I will meet the needs of: how to export the data in a MySQL simple ~!Practical!
Jmeter二次开发实现rsa加密
group of people
测试ESP32-Zigbee转发命令 : 滑轨、继电器控制
搭建直播平台,使用node生成验证码图片,并进行验证
Teach you how to kill if else
Broadcast platform, the use of the node generated captcha image, and validate
VS保存后Unity不刷新
How does Redis easily achieve system instant kill?
TDengine 在中天钢铁 GPS、 AIS 调度中的落地
谷粒商城-day14-商城业务与压力测试
【TypeScript】深入学习TypeScript类(下)
刚安装完win10专业工作站版,系统变量中Path默认值有哪些?重新建一个“PATH”变量名,会覆盖掉原先的“Path”。