DES加密
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"));