mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-04-05 17:37:54 +08:00
refactor(wxapi): 优化待验签字段字典排序方式
This commit is contained in:
parent
6d47aa5450
commit
f059387edc
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Linq;
|
||||
|
||||
@ -260,8 +260,10 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
|
||||
if (callbackNonce == null) throw new ArgumentNullException(nameof(callbackNonce));
|
||||
if (callbackSignature == null) throw new ArgumentNullException(nameof(callbackSignature));
|
||||
|
||||
ISet<string> set = new SortedSet<string>(StringComparer.Ordinal) { client.Credentials.PushToken!, callbackTimestamp, callbackNonce };
|
||||
string sign = Utilities.SHA1Utility.Hash(string.Concat(set));
|
||||
List<string> lstParams = new List<string>() { client.Credentials.PushToken!, callbackTimestamp, callbackNonce };
|
||||
lstParams.Sort(StringComparer.Ordinal);
|
||||
|
||||
string sign = Utilities.SHA1Utility.Hash(string.Concat(lstParams));
|
||||
return string.Equals(sign, callbackSignature, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
|
@ -54,13 +54,9 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
|
||||
string nonce = Guid.NewGuid().ToString("N");
|
||||
string cardType = "INVOICE";
|
||||
|
||||
ISet<string> sortedParams = new SortedSet<string>(StringComparer.Ordinal);
|
||||
sortedParams.Add(cardType);
|
||||
sortedParams.Add(timestamp);
|
||||
sortedParams.Add(client.Credentials.AppId);
|
||||
sortedParams.Add(nonce);
|
||||
sortedParams.Add(wxcardTicket);
|
||||
string cardSign = Utilities.SHA1Utility.Hash(string.Join(string.Empty, sortedParams)).ToLower();
|
||||
List<string> lstParams = new List<string>() { cardType, timestamp, client.Credentials.AppId, nonce, wxcardTicket };
|
||||
lstParams.Sort(StringComparer.Ordinal);
|
||||
string cardSign = Utilities.SHA1Utility.Hash(string.Join(string.Empty, lstParams)).ToLower();
|
||||
|
||||
return new ReadOnlyDictionary<string, string>(new Dictionary<string, string>()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user