mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-02-15 21:06:30 +08:00
#788 批量修改所有使用字符串的getBytes方法的地方,显式使用utf-8编码,以免某些场景下出问题
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.github.binarywang.wxpay.bean.notify;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
@@ -48,7 +49,7 @@ public class WxPayRefundNotifyResult extends BaseWxPayResult implements Serializ
|
||||
String reqInfoString = result.getReqInfoString();
|
||||
try {
|
||||
final String keyMd5String = DigestUtils.md5Hex(mchKey).toLowerCase();
|
||||
SecretKeySpec key = new SecretKeySpec(keyMd5String.getBytes(), "AES");
|
||||
SecretKeySpec key = new SecretKeySpec(keyMd5String.getBytes(StandardCharsets.UTF_8), "AES");
|
||||
|
||||
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
|
||||
cipher.init(Cipher.DECRYPT_MODE, key);
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
@@ -192,7 +193,7 @@ public abstract class BaseWxPayResult implements Serializable {
|
||||
this.xmlDoc = DocumentBuilderFactory
|
||||
.newInstance()
|
||||
.newDocumentBuilder()
|
||||
.parse(new ByteArrayInputStream(this.xmlString.getBytes("UTF-8")));
|
||||
.parse(new ByteArrayInputStream(this.xmlString.getBytes(StandardCharsets.UTF_8)));
|
||||
return xmlDoc;
|
||||
} catch (SAXException | IOException | ParserConfigurationException e) {
|
||||
throw new RuntimeException("非法的xml文本内容:" + this.xmlString);
|
||||
|
||||
Reference in New Issue
Block a user