mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-09-18 17:48:12 +08:00
refactor
This commit is contained in:
@@ -260,10 +260,10 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
|
||||
if (callbackNonce == null) throw new ArgumentNullException(nameof(callbackNonce));
|
||||
if (callbackSignature == null) throw new ArgumentNullException(nameof(callbackSignature));
|
||||
|
||||
List<string> lstParams = new List<string>() { client.Credentials.PushToken!, callbackTimestamp, callbackNonce };
|
||||
lstParams.Sort(StringComparer.Ordinal);
|
||||
List<string> tmp = new List<string>(capacity: 3) { client.Credentials.PushToken!, callbackTimestamp, callbackNonce };
|
||||
tmp.Sort(StringComparer.Ordinal);
|
||||
|
||||
string sign = Utilities.SHA1Utility.Hash(string.Concat(lstParams));
|
||||
string sign = Utilities.SHA1Utility.Hash(string.Concat(tmp));
|
||||
return string.Equals(sign, callbackSignature, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
|
@@ -54,9 +54,9 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
|
||||
string nonce = Guid.NewGuid().ToString("N");
|
||||
string cardType = "INVOICE";
|
||||
|
||||
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();
|
||||
List<string> tmp = new List<string>(capacity: 5) { cardType, timestamp, client.Credentials.AppId, nonce, wxcardTicket };
|
||||
tmp.Sort(StringComparer.Ordinal);
|
||||
string cardSign = Utilities.SHA1Utility.Hash(string.Concat(tmp)).ToLower();
|
||||
|
||||
return new ReadOnlyDictionary<string, string>(new Dictionary<string, string>()
|
||||
{
|
||||
|
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Security;
|
||||
using System.Security.Cryptography;
|
||||
@@ -230,14 +229,11 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Utilities
|
||||
if (sNonce == null) throw new ArgumentNullException(nameof(sNonce));
|
||||
if (sMsgEncrypt == null) throw new ArgumentNullException(nameof(sMsgEncrypt));
|
||||
|
||||
ISet<string> set = new SortedSet<string>(StringComparer.Ordinal);
|
||||
set.Add(sToken);
|
||||
set.Add(sTimestamp);
|
||||
set.Add(sNonce);
|
||||
set.Add(sMsgEncrypt);
|
||||
List<string> tmp = new List<string>(capacity: 4) { sToken, sTimestamp, sNonce, sMsgEncrypt };
|
||||
tmp.Sort(StringComparer.Ordinal);
|
||||
|
||||
string rawText = string.Join(string.Empty, set.ToArray());
|
||||
string signText = Utilities.SHA1Utility.Hash(rawText);
|
||||
string rawText = string.Join(string.Empty, tmp);
|
||||
string signText = SHA1Utility.Hash(rawText);
|
||||
return signText.ToLower();
|
||||
}
|
||||
|
||||
|
@@ -11,7 +11,7 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI
|
||||
where TEvent : WechatOpenAIEvent
|
||||
{
|
||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
||||
if (string.IsNullOrEmpty(callbackXml)) throw new ArgumentNullException(callbackXml);
|
||||
if (callbackXml == null) throw new ArgumentNullException(callbackXml);
|
||||
|
||||
try
|
||||
{
|
||||
|
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Security;
|
||||
using System.Security.Cryptography;
|
||||
@@ -230,14 +229,11 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Utilities
|
||||
if (sNonce == null) throw new ArgumentNullException(nameof(sNonce));
|
||||
if (sMsgEncrypt == null) throw new ArgumentNullException(nameof(sMsgEncrypt));
|
||||
|
||||
ISet<string> set = new SortedSet<string>(StringComparer.Ordinal);
|
||||
set.Add(sToken);
|
||||
set.Add(sTimestamp);
|
||||
set.Add(sNonce);
|
||||
set.Add(sMsgEncrypt);
|
||||
List<string> tmp = new List<string>(capacity: 4) { sToken, sTimestamp, sNonce, sMsgEncrypt };
|
||||
tmp.Sort(StringComparer.Ordinal);
|
||||
|
||||
string rawText = string.Join(string.Empty, set.ToArray());
|
||||
string signText = Utilities.SHA1Utility.Hash(rawText);
|
||||
string rawText = string.Join(string.Empty, tmp);
|
||||
string signText = SHA1Utility.Hash(rawText);
|
||||
return signText.ToLower();
|
||||
}
|
||||
|
||||
|
@@ -32,7 +32,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
where TEvent : WechatWorkEvent
|
||||
{
|
||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
||||
if (string.IsNullOrEmpty(callbackJson)) throw new ArgumentNullException(callbackJson);
|
||||
if (callbackJson == null) throw new ArgumentNullException(callbackJson);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -58,7 +58,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
where TEvent : WechatWorkEvent
|
||||
{
|
||||
if (client == null) throw new ArgumentNullException(nameof(client));
|
||||
if (string.IsNullOrEmpty(callbackXml)) throw new ArgumentNullException(callbackXml);
|
||||
if (callbackXml == null) throw new ArgumentNullException(callbackXml);
|
||||
|
||||
try
|
||||
{
|
||||
|
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Security;
|
||||
using System.Security.Cryptography;
|
||||
@@ -230,14 +229,11 @@ namespace SKIT.FlurlHttpClient.Wechat.Work.Utilities
|
||||
if (sNonce == null) throw new ArgumentNullException(nameof(sNonce));
|
||||
if (sMsgEncrypt == null) throw new ArgumentNullException(nameof(sMsgEncrypt));
|
||||
|
||||
ISet<string> set = new SortedSet<string>(StringComparer.Ordinal);
|
||||
set.Add(sToken);
|
||||
set.Add(sTimestamp);
|
||||
set.Add(sNonce);
|
||||
set.Add(sMsgEncrypt);
|
||||
List<string> tmp = new List<string>(capacity: 4) { sToken, sTimestamp, sNonce, sMsgEncrypt };
|
||||
tmp.Sort(StringComparer.Ordinal);
|
||||
|
||||
string rawText = string.Join(string.Empty, set.ToArray());
|
||||
string signText = Utilities.SHA1Utility.Hash(rawText);
|
||||
string rawText = string.Join(string.Empty, tmp);
|
||||
string signText = SHA1Utility.Hash(rawText);
|
||||
return signText.ToLower();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user