First of all, write a function according to the phone number generated encrypted string, and exported as a jar package, function specific content omitted, there are many online
Place the jar package under the JMeter lib\ext directory and add the path to the user.properties.
Create a BeanShell preprocessor, which is a pre-beanshell that will generate the mobile and signature I need before I send a request.
Concrete structure
The body data of my request is as follows:
{ "mobile":"${mobile}", " Signature":"${sin}"}
BeanShell Inside:
Import Tools.md5util; Md5util MD5=new md5util (); Vars.put ("str"= Vars.get ("str"); Vars.put ("sin", test.substring (0,32)); Vars.put (" Mobile ", test.substring (33));
There's a hole here that needs to convert the JMeter variable into a variable BeanShell know, String test = Vars.get This step is more important
Tried many times with ${str} to fetch the value directly, BeanShell does not treat it as a variable, but only as a string.
Printing results as follows, see the results should know, I encapsulated the method returned the signature + "," + mobile phone number, such as the variable str display, so I did in BeanShell inside the interception string processing:
Jmeter BeanShell Generate phone number encryption signature