提交 a1f8f72e authored 作者:  狄熙卜's avatar 狄熙卜

修改报错方式

上级 55af4911
...@@ -2,16 +2,18 @@ package cn.gtmap.bdcdj.core.encrypt.utils; ...@@ -2,16 +2,18 @@ package cn.gtmap.bdcdj.core.encrypt.utils;
import cn.gtmap.bdcdj.core.encrypt.CryptProperties; import cn.gtmap.bdcdj.core.encrypt.CryptProperties;
import cn.gtmap.bdcdj.core.encrypt.enums.SaltsEnum; import cn.gtmap.bdcdj.core.encrypt.enums.SaltsEnum;
import cn.gtmap.bdcdj.core.encrypt.executor.CryptExecutorFactory;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.pqc.math.linearalgebra.ByteUtils; import org.bouncycastle.pqc.math.linearalgebra.ByteUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.crypto.BadPaddingException; import javax.crypto.BadPaddingException;
import javax.crypto.Cipher; import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException; import javax.crypto.IllegalBlockSizeException;
import javax.crypto.KeyGenerator; import javax.crypto.KeyGenerator;
import javax.crypto.spec.SecretKeySpec; import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.StandardCharsets;
import java.security.Key; import java.security.Key;
import java.security.SecureRandom; import java.security.SecureRandom;
import java.security.Security; import java.security.Security;
...@@ -23,6 +25,7 @@ public class GmSm4Util { ...@@ -23,6 +25,7 @@ public class GmSm4Util {
public static final String ALGORITHM_NAME_ECB_PADDING = "SM4/ECB/PKCS5Padding"; public static final String ALGORITHM_NAME_ECB_PADDING = "SM4/ECB/PKCS5Padding";
public static final int DEFAULT_KEY_SIZE = 128; public static final int DEFAULT_KEY_SIZE = 128;
private static final Logger LOGGER = LoggerFactory.getLogger(GmSm4Util.class);
public GmSm4Util() { public GmSm4Util() {
} }
...@@ -212,13 +215,14 @@ public class GmSm4Util { ...@@ -212,13 +215,14 @@ public class GmSm4Util {
try { try {
return cipher.doFinal(cipherText); return cipher.doFinal(cipherText);
} catch (IllegalBlockSizeException e) { } catch (IllegalBlockSizeException e) {
e.printStackTrace(); LOGGER.info("解密失败,IllegalBlockSizeException");
return "加密字段错误,请联系管理员检查,error:1".getBytes("UTF-8"); return "加密字段错误,请联系管理员检查,error:1".getBytes("UTF-8");
} catch (BadPaddingException e) { } catch (BadPaddingException e) {
e.printStackTrace(); LOGGER.info("解密失败,BadPaddingException");
return "加密字段错误,请联系管理员检查,error:2".getBytes("UTF-8"); return "加密字段错误,请联系管理员检查,error:2".getBytes("UTF-8");
} }
}else{ }else{
LOGGER.info("解密失败");
return "加密字段错误,请联系管理员检查,error:3".getBytes("UTF-8"); return "加密字段错误,请联系管理员检查,error:3".getBytes("UTF-8");
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论