2022-05-24 09:23:17 +08:00
|
|
|
package com.engine.salary.encrypt;
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import weaver.general.AES;
|
|
|
|
|
import weaver.general.BaseBean;
|
|
|
|
|
|
|
|
|
|
public class AESEncryptUtil {
|
|
|
|
|
|
2022-07-13 13:55:31 +08:00
|
|
|
static BaseBean bb = new BaseBean();
|
|
|
|
|
|
|
|
|
|
static String aesEncryptScrect = bb.getPropValue("hrmSalary", "AESEncryptScrect");
|
|
|
|
|
|
2022-05-24 09:23:17 +08:00
|
|
|
/**
|
|
|
|
|
* AES加密
|
2022-07-13 13:55:31 +08:00
|
|
|
*
|
2022-05-24 09:23:17 +08:00
|
|
|
* @param source 原始数据
|
|
|
|
|
* @return 加密数据
|
|
|
|
|
*/
|
|
|
|
|
public static String encrypt(String source) {
|
2022-07-13 13:55:31 +08:00
|
|
|
if (StringUtils.isNotBlank(source)) {
|
2022-05-24 09:23:17 +08:00
|
|
|
return AES.encrypt(source, aesEncryptScrect);
|
|
|
|
|
}
|
|
|
|
|
return source;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* AES解密
|
2022-07-13 13:55:31 +08:00
|
|
|
*
|
2022-05-24 09:23:17 +08:00
|
|
|
* @param encryptStr 加密字符串
|
|
|
|
|
* @return 解密字符串
|
|
|
|
|
*/
|
|
|
|
|
public static String decrypt(String encryptStr) {
|
2022-07-13 13:55:31 +08:00
|
|
|
if (StringUtils.isNotBlank(encryptStr)) {
|
2022-05-24 09:23:17 +08:00
|
|
|
return AES.decrypt(encryptStr, aesEncryptScrect);
|
|
|
|
|
}
|
|
|
|
|
return encryptStr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|