From 532f405c768b085531ce0704c7b3214d45bfbae4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 22 Sep 2025 16:27:01 +0000 Subject: [PATCH 1/2] Initial plan From fc129b987ec8f0d822d0829acc11a0457a12bdd4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 22 Sep 2025 16:36:43 +0000 Subject: [PATCH 2/2] Fix AES key charset encoding issue in WxPay decryptToString method Co-authored-by: binarywang <1343140+binarywang@users.noreply.github.com> --- .../java/com/github/binarywang/wxpay/v3/util/AesUtils.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/AesUtils.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/AesUtils.java index b4a97ba88f..831dfe2bb1 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/AesUtils.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/v3/util/AesUtils.java @@ -80,11 +80,11 @@ public static String decryptToString(String associatedData, String nonce, String try { Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding"); - SecretKeySpec key = new SecretKeySpec(apiV3Key.getBytes(), "AES"); - GCMParameterSpec spec = new GCMParameterSpec(TAG_LENGTH_BIT, nonce.getBytes()); + SecretKeySpec key = new SecretKeySpec(apiV3Key.getBytes(StandardCharsets.UTF_8), "AES"); + GCMParameterSpec spec = new GCMParameterSpec(TAG_LENGTH_BIT, nonce.getBytes(StandardCharsets.UTF_8)); cipher.init(Cipher.DECRYPT_MODE, key, spec); - cipher.updateAAD(associatedData.getBytes()); + cipher.updateAAD(associatedData.getBytes(StandardCharsets.UTF_8)); return new String(cipher.doFinal(Base64.getDecoder().decode(ciphertext)), StandardCharsets.UTF_8); } catch (NoSuchAlgorithmException | NoSuchPaddingException e) {