import java.util.Base64;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import javax.crypto.spec.IvParameterSpec;
String key ="*******";//引用key
String body=vars.get("codebody");
//vars.get("codebody");//引用参数
//print("?????????........"+CartID);
// 加密方法
public String EncryptAsDoNet(String message) {
try {
Base64.Encoder encoder = Base64.getEncoder();
Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding");
DESKeySpec desKeySpec = new DESKeySpec(key.getBytes("UTF-8"));
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
SecretKey secretKey = keyFactory.generateSecret(desKeySpec);
IvParameterSpec iv = new IvParameterSpec(key.getBytes("UTF-8"));
cipher.init(Cipher.ENCRYPT_MODE, secretKey, iv);
byte[] encryptbyte = cipher.doFinal(message.getBytes());
String str =encoder.encodeToString(encryptbyte);
return str.replace("\n", "");
}catch (Throwable e) {
e.printStackTrace();
return "";
}
}
// 加密
String DESSign = EncryptAsDoNet(body);
//print(enString);
//${__setProperty("NewenString",${enString},)};
vars.put("DESSign",DESSign);
log.info("请求登陆验证码参数"+body);
//print(props.get("NewenString"));
相关文章
- 02-02冰蝎动态二进制加密WebShell特征分析
- 02-02冰蝎动态二进制加密WebShell基于流量侧检测方案
- 02-02MD5 32位 小写加密和大写加密
- 02-02BUAA(2021春)加密文件——分步骤一步一步有逻辑性完成
- 02-02外媒:伊朗**加密通讯应用Signal
- 02-02AES加密补位填充的一个问题
- 02-02幂数加密
- 02-02SSIS包加密
- 02-02如何加密ncnn模型
- 02-02启用chacha20和salsa20等加密方法