对文件的加密解密
但是这样写的工具类Cipher ,会出现一个异常,
在Linux中会解密失败,具体解决办法,见另一篇博客:https://blog..net/weixin_43276786/article/details/90381086
工具类:
package cn.com.dh.util;
import java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
public class AesHelper {
// 指定加密key
private static String RANDOM_KEY="erdws32wq43e4r5t6fdszxdcvgbhjijkiu8iu9oplikjuyteq1qazxcbnmkbcdxs";
// 获取默认加密cipher
public static Cipher getEncryptCipher() throws Exception{
return getCipher(Cipher.ENCRYPT_MODE);
}
// 获取默认解密cipher
public static Cipher getDecryptCipher() throws Exception{
return getCipher(Cipher.DECRYPT_MODE);
}
public static