微调
This commit is contained in:
@@ -0,0 +1,63 @@
|
|||||||
|
package com.njcn.common.utils;
|
||||||
|
|
||||||
|
import com.njcn.common.utils.sm.Sm4Utils;
|
||||||
|
import com.njcn.common.utils.sm.ThreeDesUtil;
|
||||||
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pqs
|
||||||
|
*
|
||||||
|
* @author cdf
|
||||||
|
* @date 2022/1/6
|
||||||
|
*/
|
||||||
|
public class EncryptionUtil {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cd 系统配置的解密方式
|
||||||
|
* content 需要解密的内容
|
||||||
|
* 解密对应内容
|
||||||
|
*
|
||||||
|
* @author cdf
|
||||||
|
* @date 2021/10/12
|
||||||
|
*/
|
||||||
|
public static String decoderString(Integer cd, String content) {
|
||||||
|
String seriesTmp = null;
|
||||||
|
if (cd == 0) {
|
||||||
|
seriesTmp = Base64.decodeBase64(content).toString();
|
||||||
|
} else if (cd == 1) {
|
||||||
|
seriesTmp = ThreeDesUtil.decryptThreeDes(content);
|
||||||
|
} else if (cd == 2) {
|
||||||
|
//SM4加密密码
|
||||||
|
String secretkey = Sm4Utils.globalSecretKey;
|
||||||
|
Sm4Utils sm4 = new Sm4Utils(secretkey);
|
||||||
|
seriesTmp = sm4.decryptData_ECB(content);
|
||||||
|
}
|
||||||
|
return seriesTmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cd 系统配置的加密方式
|
||||||
|
* content 需要加密的内容
|
||||||
|
* 加密对应内容
|
||||||
|
*
|
||||||
|
* @author cdf
|
||||||
|
* @date 2021/10/12
|
||||||
|
*/
|
||||||
|
public static String encodeString(Integer cd, String content) {
|
||||||
|
String key = null;
|
||||||
|
if (cd == 0) {
|
||||||
|
key = Base64.encodeBase64String(content.getBytes());
|
||||||
|
} else if (cd == 1) {
|
||||||
|
key = ThreeDesUtil.encryptThreeDes(content);
|
||||||
|
} else if (cd == 2) {
|
||||||
|
//SM4加密密码
|
||||||
|
// String secretkey = Sm4Utils.globalSecretKey;
|
||||||
|
// Sm4Utils sm4 = new Sm4Utils(secretkey);
|
||||||
|
// key = sm4.encryptData_ECB(content);
|
||||||
|
}
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user