一个加密函数
public static byte[] encryptMode(byte[] keyBytes, byte[] plainBytes) {
try {
// 添加新安全算法:PKCS7
Security.addProvider(new BouncyCastleProvider());
SecretKey deskey = new SecretKeySpec(keyBytes, ALGORITHM); // 生成密钥
// 解密的Cipher工具类
Cipher cipher = Cipher.getInstance(ALGORITHM); // 实例化负责加密
cipher.init(Cipher.ENCRYPT_MODE, deskey); // 初始化为加密模式
return cipher.doFinal(plainBytes);
} catch (NoSuchAlgorithmException e1) {
LOG.error("NoSuchAlgorithm error: {}", e1);
} catch (NoSuchPaddingException e2) {
LOG.error("NoSuchPadding error: {}", e2);
} catch (Exception e3) {
LOG.error("Error occur {}", e3);
}
return new byte[0];
}
有疑问加站长微信联系(非本文作者)

这是刺果果的白嫖
10元,加微信告诉你
这个常量 ALGORITHM 是?
Go对应代码
不用,写出来了
只是比较忙而已,已经弄出来了