1
0
mirror of synced 2025-11-06 04:20:53 +08:00

Compare commits

...

2 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
fc129b987e Fix AES key charset encoding issue in WxPay decryptToString method
Co-authored-by: binarywang <1343140+binarywang@users.noreply.github.com>
2025-09-22 16:36:43 +00:00
copilot-swe-agent[bot]
532f405c76 Initial plan 2025-09-22 16:27:01 +00:00

View File

@@ -80,11 +80,11 @@ public class AesUtils {
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) {