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

bug修复

上级 5b312b26
...@@ -2,7 +2,6 @@ package cn.gtmap.bdcdj.core.encrypt.utils; ...@@ -2,7 +2,6 @@ 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 org.apache.commons.codec.binary.Base64;
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;
...@@ -79,7 +78,7 @@ public class GmSm4Util { ...@@ -79,7 +78,7 @@ public class GmSm4Util {
try { try {
byte[] srcData = paramStr.getBytes(encoding); byte[] srcData = paramStr.getBytes(encoding);
byte[] cipherArray = encrypt_Ecb_Padding(keyData, srcData); byte[] cipherArray = encrypt_Ecb_Padding(keyData, srcData);
return salt + Base64.encodeBase64String(cipherArray); return salt + ByteUtils.toHexString(cipherArray);
} catch (Exception var8) { } catch (Exception var8) {
throw new RuntimeException(var8); throw new RuntimeException(var8);
} }
...@@ -161,16 +160,16 @@ public class GmSm4Util { ...@@ -161,16 +160,16 @@ public class GmSm4Util {
if (StringUtils.startsWithIgnoreCase(cipherText, salt)) { if (StringUtils.startsWithIgnoreCase(cipherText, salt)) {
if (StringUtils.endsWith(cipherText, "等")) { if (StringUtils.endsWith(cipherText, "等")) {
String realCipherText = StringUtils.removeEnd(StringUtils.removeStartIgnoreCase(cipherText, salt), "等"); String realCipherText = StringUtils.removeEnd(StringUtils.removeStartIgnoreCase(cipherText, salt), "等");
srcData = Base64.decodeBase64(realCipherText); srcData = ByteUtils.fromHexString(realCipherText);
srcData = decrypt_Ecb_Padding(keyData, srcData); srcData = decrypt_Ecb_Padding(keyData, srcData);
return new String(srcData, encoding) + "等"; return new String(srcData, encoding) + "等";
} else { } else {
cipherData = Base64.decodeBase64(StringUtils.removeStartIgnoreCase(cipherText, salt)); cipherData = ByteUtils.fromHexString(StringUtils.removeStartIgnoreCase(cipherText, salt));
srcData = decrypt_Ecb_Padding(keyData, cipherData); srcData = decrypt_Ecb_Padding(keyData, cipherData);
return new String(srcData, encoding); return new String(srcData, encoding);
} }
} else { } else {
cipherData = Base64.decodeBase64(cipherText); cipherData = ByteUtils.fromHexString(cipherText);
srcData = decrypt_Ecb_Padding(keyData, cipherData); srcData = decrypt_Ecb_Padding(keyData, cipherData);
return new String(srcData, encoding); return new String(srcData, encoding);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论