jmeter的beanshell无法导入jar包
beanshell中使用第三方jar包(web3j)无法使用,报错如下
2023-05-22 17:12:00,327 ERROR o.a.j.u.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: `` import org.web3j.crypto.Credentials; import org.web3j.crypto.Hash; import org.w . . . '' : Typed variable declaration
2023-05-22 17:12:00,328 WARN o.a.j.m.BeanShellPreProcessor: Problem in BeanShell script. org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: `` import org.web3j.crypto.Credentials; import org.web3j.crypto.Hash; import org.w . . . '' : Typed variable declaration
2023-05-22 17:12:00,369 INFO o.a.j.u.BeanShellTestElement: 签名数据Welcome to Decert!\n\nThis request will not trigger a blockchain transaction or cost any gas fees.\n\nYour authentication status will reset after 24 hours.\n\nWallet address:\n0xEDC7A0D20A563f9948D2D1332937b5f04F9670A2\n\nNonce:\neda03cda-82b3-4666-8834-89137ee0189c
我将jar包放在相关文件夹中,配置了配置文件,也试过放在lib/ext中,以下是相关代码
import org.bouncycastle.util.encoders.Hex;
import org.web3j.crypto.Credentials;
import org.web3j.crypto.Hash;
import org.web3j.crypto.Keys;
import org.web3j.crypto.Sign;
import org.bouncycastle.util.encoders.Hex;
// 钱包私钥
String priKey = "xxxxx";
// 钱包地址
String walletAddress = "0xxxxxxxxxxxx";
// 原文
String content = vars.get("message");
// 原文摘要字节数组
byte[] contentHashBytes = Hash.sha3(content.getBytes());
// 原文摘要16进制字符串
String contentHashHex = Hex.toHexString(contentHashBytes);
Credentials credentials = Credentials.create(priKey);
Sign.SignatureData signMessage = Sign.signPrefixedMessage(contentHashBytes, credentials.getEcKeyPair());
System.out.println(Hex.toHexString(signMessage.getR()));
System.out.println(Hex.toHexString(signMessage.getS()));
System.out.println(Hex.toHexString(signMessage.getV()));
// 签名后的字符串
String signStr = "0x" + Hex.toHexString(signMessage.getR()) + Hex.toHexString(signMessage.getS()) + Hex.toHexString(signMessage.getV());
System.out.println("signStr=" + signStr);
log.info(signStr);
钱包地址,私钥均隐藏可以根据自己实际填写,以上代码是web3进行签名的操作。
希望有大佬能够给一些解决方案,不胜感激
...全文
相关推荐
JMeter导入自定义的Jar包的详解教程
主要介绍了JMeter导入自定义的Jar包的详解教程,本文通过图文并茂的形式给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
Jmeter接口测试之jar包引入&beanshell;脚本编写
Jmeter接口测试过程中,遇到需要jar包引入时需要怎么做?调试成功后的脚本,完全step by step教程
Jmeter需要用的json.jar包
使用beanshell提取响应信息是 json格式,需要导入.jar包到jmeter安装目录lib下
jmeter jar包
jmeter beanshell json 所需的jar包,一般在使用beanShell 插件时使用,需要放入jmeter lib exa 目录下
JMeter beanShell修改http请求参数
JMeter beanShell修改http请求参数,尝试对http进行修改。


