Jmeter BeanShell Generate phone number encryption signature

Source: Internet
Author: User
Tags vars

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.