背景:和同行讨论时提起对Excel等文件进行保存时,如何文件泄露后数据被直接看到,讨论了许多种方法,分割存储,打包文件压缩后加密,对文件加密等,于是了解了一下Java这方面的知识,写了一个对文件加密的工具类
package crypto.CipherUtils;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import java.io.*;
import java.security.SecureRandom;
/**
* @description:
* @author: hinotoyk
* @create: 2020-06-25 20:44
**/
public enum EncryptUtils {
ENCRYPT_UTILS;
/**
* 密钥算法
*/
private static final String ALGORITHM = "AES";
/**
* 加解密算法/工作模式/填充方式
*/
private static final String ALGORITHM_STR = "AES/ECB/PKCS5Padding";
private static final String SECRET_KEY = "hinotoyk";
<