mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-10-15 10:45:15 +08:00
#319 增加“退款结果通知“处理方法,并优化调整微信支付相关代码
This commit is contained in:
@@ -47,7 +47,6 @@ public class WxCryptUtil {
|
||||
protected String appidOrCorpid;
|
||||
|
||||
public WxCryptUtil() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,7 +105,7 @@ public class WxCryptUtil {
|
||||
private static String genRandomStr() {
|
||||
String base = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
Random random = new Random();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < 16; i++) {
|
||||
int number = random.nextInt(base.length());
|
||||
sb.append(base.charAt(number));
|
||||
@@ -148,12 +147,11 @@ public class WxCryptUtil {
|
||||
String encryptedXml = encrypt(genRandomStr(), plainText);
|
||||
|
||||
// 生成安全签名
|
||||
String timeStamp = Long.toString(System.currentTimeMillis() / 1000l);
|
||||
String timeStamp = Long.toString(System.currentTimeMillis() / 1000L);
|
||||
String nonce = genRandomStr();
|
||||
|
||||
String signature = SHA1.gen(this.token, timeStamp, nonce, encryptedXml);
|
||||
String result = generateXml(encryptedXml, signature, timeStamp, nonce);
|
||||
return result;
|
||||
return generateXml(encryptedXml, signature, timeStamp, nonce);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -194,9 +192,7 @@ public class WxCryptUtil {
|
||||
byte[] encrypted = cipher.doFinal(unencrypted);
|
||||
|
||||
// 使用BASE64对加密后的字符串进行编码
|
||||
String base64Encrypted = base64.encodeToString(encrypted);
|
||||
|
||||
return base64Encrypted;
|
||||
return base64.encodeToString(encrypted);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -228,8 +224,7 @@ public class WxCryptUtil {
|
||||
}
|
||||
|
||||
// 解密
|
||||
String result = decrypt(cipherText);
|
||||
return result;
|
||||
return decrypt(cipherText);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user