AES 加密、解密源码见另一篇博客:https://blog.csdn.net/weixin_43276786/article/details/90288171
在windows下运行正常,对加密后的密文可以正常解密,
但是放到linux上运行,则报错,错误信息如下
原因:
经过检查之后,定位在生成KEY的方法上,即如下红色代码:
public static Cipher getCipher(int model) throws Exception{
//1.获取加密生成器
KeyGenerator keygen=KeyGenerator.getInstance("AES");
//2.根据ecnodeRules规则初始化密钥生成器
//生成一个128位的随机源,根据传入的字节数组
keygen.init(128, new SecureRandom(RANDOM_KEY.getBytes()));
//3.产生原始对称密钥
SecretKey original