Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Jmeter completes the API request parameters for md5 encryption

Shulou Source: shulou.com Published: 2022-06-03 06:47:44 09月25日 Update

Baidu search: Xiaoqiang Test Brand

Kick talk shows, entertain technology and systematize fragments, all in Litchi FM (http://www.lizhi.fm/200893)

"Xiaoqiang Software testing Crazy handout-performance and Automation" has been published and can be purchased by all online stores.

It is not difficult for jmeter to complete the interface test. For basic use, you can watch my video: http://edu.51cto.com/course/course_id-2324.html

But sometimes the parameters we request may need to be encrypted, for example, the password in the login interface may need to be encrypted by md5.

The first method:

This method is relatively simple, jmeter has a built-in function of md5, which can be used directly. Parameter username is the user name, which is entered normally, and password is the password encrypted by md5.

If you don't have this function, install it, as shown in the figure

The second method:

Some programming skills are required, which can be done with beanshell. The general steps are as follows:

1. The algorithm for exporting md5 is jar package, which can be completed with the help of the developer.

2. Copy the jar package to the lib/ext file directory of jmeter

3. Create a new beanshell sampler in jmeter and write code

Import hehe.md5.Str2MD5;// package name, not known for developer

String res = newStr2MD5 () .MD5 ("xiaoqiang"); / / new an object and call the method to get the encrypted return

System.out.println (res); / / print the result

Vars.put ("md5", res.toString ()); / / Save the encrypted data into the variable md5 for use in jmeter

Tags: Encryption methods tests parameters interfaces functions passwords Xiaoqiang technology development madness code variables brands objects performance data files and sometimes steps Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Xiaomi MySQL Shulou Tech Info Huawei