From 6f670e8408a0bc1c3275ff806dae8e354c57c017 Mon Sep 17 00:00:00 2001 From: lbw Date: Wed, 21 Jun 2023 14:32:31 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20Fixing=20a=20bug.=20=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E6=8A=A5=E6=96=87AES=20=E5=8A=A0=E5=AF=86=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pigx/common/api/encrypt/util/ApiCryptoUtil.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pigx-common/pigx-common-encrypt-api/src/main/java/com/pig4cloud/pigx/common/api/encrypt/util/ApiCryptoUtil.java b/pigx-common/pigx-common-encrypt-api/src/main/java/com/pig4cloud/pigx/common/api/encrypt/util/ApiCryptoUtil.java index 17a06683e..64612fcfd 100644 --- a/pigx-common/pigx-common-encrypt-api/src/main/java/com/pig4cloud/pigx/common/api/encrypt/util/ApiCryptoUtil.java +++ b/pigx-common/pigx-common-encrypt-api/src/main/java/com/pig4cloud/pigx/common/api/encrypt/util/ApiCryptoUtil.java @@ -123,10 +123,12 @@ public class ApiCryptoUtil { Assert.hasText(secretKey, type + " key is not configured (未配置" + type + ")"); if (type == EncryptType.AES) { - // 构建前端对应解密AES 因子 - AES aes = new AES(Mode.CFB, Padding.NoPadding, new SecretKeySpec(secretKey.getBytes(), "AES"), - new IvParameterSpec(secretKey.getBytes())); - return aes.decrypt(StrUtil.str(bodyData, Charset.defaultCharset())); + + AES aes = new AES(Mode.CFB, Padding.NoPadding, + new SecretKeySpec(secretKey.getBytes(StandardCharsets.UTF_8), "AES"), + new IvParameterSpec(secretKey.getBytes(StandardCharsets.UTF_8))); + return aes.decrypt(StrUtil.str(bodyData, StandardCharsets.UTF_8)); + } if (type == EncryptType.DES) { return SecureUtil.des(secretKey.getBytes(StandardCharsets.UTF_8)).decrypt(bodyData);