一个加密函数
```java
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];
}
```