Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement Base64 coding with Jmeter

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Most people do not understand the knowledge points of this article "Jmeter how to achieve Base64 coding", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "Jmeter how to achieve Base64 coding" article.

There are two ways for Jmeter to implement Base64 encoding:

1. If the installed version of Jmeter provides a built-in Base64 encryption function, you can directly use the built-in function as follows:

Click Tools-- > function Assistant dialog box

Find the built-in Base64 encryption function and select _ _ base64Encode

2. If the installed version of Jmeter does not have a built-in Base64 encryption function, then if you need Base64 encryption, you can only implement it through BeanShell script as follows:

Import org.apache.commons.net.util.Base64 String source = "{\" admin\ ": false,\" company\ ":\" osc\ ",\" companyIdentity\ ":\" COMPANY_OWNER\ ",\" displayName\ ":\" osc-admin\ ",\" email\ ":\" osc-admin@test.com\ ",\" id\ ":\" 1\ ",\" sAMAccountName\ ":\" osc-admin\ ",\" status\ ":\" SUCCESS\ ",\" uSNCreated\ ":\" 1\ " \ "userPrincipalName\":\ "osc-admin@test.com\",\ "username\":\ "osc-admin\"} " Byte [] encodedBytes = Base64.encodeBase64 (source.getBytes ("UTF-8")); String encoded = new String (encodedBytes); vars.put ("sessionToken", encoded)

Note: strings cannot be in single quotation marks!

Add: implement base64 encryption in Jmeter

Jmeter no longer provides built-in base64 encryption functions. If you meet the encryption requirements of base64, you need to implement them through beanshell.

Go directly to the beanshell code:

Import org.apache.commons.net.util.Base64; / / String source = vars.get ("name"); String source = Harry Potter; byte [] encodedBytes = Base64.encodeBase64 (source.getBytes ("UTF-8")); String encoded = new String (encodedBytes); vars.put ("b64", encoded) The above is about the content of this article on "how to achieve Base64 coding in Jmeter". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more related knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report