1,打开eclipse,新建maven工程,在pom中引用jmeter核心jar包,具体请看---https://www.cnblogs.com/guanyf/p/10863033.html---,这里就不再赘述

2,直接上代码:

  

package com.mytest.functions;

import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import org.apache.jmeter.engine.util.CompoundVariable;
import org.apache.jmeter.functions.AbstractFunction;
import org.apache.jmeter.functions.InvalidVariableException;
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.samplers.Sampler;
import org.apache.jmeter.threads.JMeterVariables;
import sun.misc.BASE64Encoder; public class Base64 extends AbstractFunction
{
private static final List<String> desc = new LinkedList();
private static final String KEY = "__Base64_string";
private Object[] values; public synchronized String execute(SampleResult paramSampleResult, Sampler paramSampler)
throws InvalidVariableException
{
JMeterVariables localJMeterVariables = getVariables();
String str1 = ((CompoundVariable)this.values[]).execute(); String str2 = new BASE64Encoder().encode(str1.getBytes()); if ((localJMeterVariables != null) && (this.values.length > )) {
String str3 = ((CompoundVariable)this.values[]).execute().trim();
localJMeterVariables.put(str3, str2);
} return str2;
} public synchronized void setParameters(Collection<CompoundVariable> paramCollection)
throws InvalidVariableException
{
checkMinParameterCount(paramCollection, );
this.values = paramCollection.toArray();
} public String getReferenceKey()
{
return "__Base64_string";
} public List<String> getArgumentDesc()
{
return desc;
} static
{
desc.add("String to calculate Base64 hash ");
desc.add("Name of variable in which to store the result (optional),作者:guanyf");
}
}

3,打包 jar ,放入指定位置就可以马上使用

jmeter添加自定义扩展函数之String---base64加密的更多相关文章

  1. jmeter添加自定义扩展函数之图片base64编码

    打开eclipse,新建maven工程,在pom中引入jmeter核心jar包: <!-- https://mvnrepository.com/artifact/org.apache.jmete ...

  2. jmeter添加自定义扩展函数之图片base64

    原文连接:---------https://www.cnblogs.com/qiaoyeye/p/7218770.html----------- 打开eclipse,新建maven工程,在pom中引用 ...

  3. jmeter添加自定义扩展函数之MD5加密

    1,打开eclipse,新建maven工程,在pom中引用jmeter核心jar包,具体请看---https://www.cnblogs.com/guanyf/p/10863033.html---,这 ...

  4. jmeter添加自定义扩展函数之Strng---base64解密

    1,打开eclipse,新建maven工程,在pom中引用jmeter核心jar包,具体请看---https://www.cnblogs.com/guanyf/p/10863033.html---,这 ...

  5. jmeter添加自定义扩展函数之DoubleSum

    1,打开eclipse,新建maven工程,在pom中引用jmeter核心jar包,具体请看---https://www.cnblogs.com/guanyf/p/10863033.html---,这 ...

  6. jmeter添加自定义扩展函数之if判断

    1,打开eclipse,新建maven工程,在pom中引用jmeter核心jar包,具体请看---https://www.cnblogs.com/guanyf/p/10863033.html---,这 ...

  7. jmeter添加自定义扩展函数之小写转换大写

    1,打开eclipse,新建maven工程,在pom中引用jmeter核心jar包,具体请看---https://www.cnblogs.com/guanyf/p/10863033.html---,这 ...

  8. jmeter添加自定义扩展函数之大写转换小写

    1,打开eclipse,新建maven工程,在pom中引用jmeter核心jar包,具体请看---https://www.cnblogs.com/guanyf/p/10863033.html---,这 ...

  9. Jmeter编写Base64加密函数

    方法一: 使用Beanshell Sampler.BSF Sampler等实现,现已Base64加密为例,脚本如下: import sun.misc.BASE64Decoder; String res ...

随机推荐

  1. P5468 [NOI2019]回家路线

    传送门 看题目一眼斜率优化,然后写半天调不出来 结果错误的 $dfs$ 有 $95$ 分?暴力 $SPFA$ 就 $AC$ 了? 讲讲正解: 显然是斜率优化的式子: 先不考虑 $q_{s_k}$ 的贡 ...

  2. ls命令输出文件的绝对路径

    find $PWD | xargs ls -ld 再结合 grep 筛选

  3. 修改 IIS 默认文件上传大小

    IIS 7 默认文件上传大小是30M 要突破这个限制: 修改IIS的applicationhost.config 打开 c:/windows/system32/inetsrv/config/appli ...

  4. 你创不出伟大的事业,因为……

    你认为自己是对的,而别人都不了解.你忙著实现自己的梦想,却不管你的梦想对这世界有什么意义.你成天想著自己的问题,对别人的问题却提不起任何兴趣. 你活在自己的世界 你认为自己是对的,而别人都不了解.你忙 ...

  5. 关于行内元素,内联元素before和after的大小设置问题

    :before /:after伪元素默认是一个行内元素,所以这个元素设置width/height是无效的

  6. procixx地址

    \\192.168.35.7\Download\Builds\procixx_psoc

  7. Mongodb Capped Collection集合

    MongoDB 固定集合(Capped Collections)是性能出色且有着固定大小的集合,对于大小固定,我们可以想象其就像一个环形队列,当集合空间用完后,再插入的元素就会覆盖最初始的头部的元素! ...

  8. Go 迭代切片

    迭代切片有两种方式: 1. 使用 for range 迭代切片   // 其长度和容量都是 4 个元素 slice := [], , , } // 迭代每一个元素,并显示其值 for index, v ...

  9. jupyter notebook 几个方法

    2. Pretty Display of Varibles 这部分内容可能很多人都知道.如果对带有一个变量或是未赋值语句的cell执行操作,Jupyter 将会自动打印该变量而无需一个输出语句. 如果 ...

  10. 正确读取resources目录下的文件

    问题描述:本地可以正常读取areacode.json文件,打成jar包在测试环境找不到该文件. 问题代码: static { StringBuffer strbuffer = new StringBu ...