mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-12-29 18:04:42 +08:00
feat: 移除基础依赖库,升级公共组件,并适配 .NET 6.0
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net461; netstandard2.0; net5.0</TargetFrameworks>
|
||||
<TargetFrameworks>net461; netstandard2.0; net5.0; net6.0</TargetFrameworks>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<NullableReferenceTypes>true</NullableReferenceTypes>
|
||||
@@ -28,11 +28,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="JWT" Version="8.4.2" />
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SKIT.FlurlHttpClient.Wechat\SKIT.FlurlHttpClient.Wechat.csproj" />
|
||||
</ItemGroup>
|
||||
<PackageReference Include="SKIT.FlurlHttpClient.Common" Version="2.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// SHA-1 算法工具类。
|
||||
/// </summary>
|
||||
public static class SHA1Utility
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取信息摘要。
|
||||
/// </summary>
|
||||
/// <param name="bytes">信息字节数组。</param>
|
||||
/// <returns>信息摘要。</returns>
|
||||
public static string Hash(byte[] bytes)
|
||||
{
|
||||
if (bytes == null) throw new ArgumentNullException(nameof(bytes));
|
||||
|
||||
using SHA1 sha = SHA1.Create();
|
||||
byte[] hashBytes = sha.ComputeHash(bytes);
|
||||
return BitConverter.ToString(hashBytes).Replace("-", "");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取信息摘要。
|
||||
/// </summary>
|
||||
/// <param name="message">文本信息。</param>
|
||||
/// <returns>信息摘要。</returns>
|
||||
public static string Hash(string message)
|
||||
{
|
||||
if (message == null) throw new ArgumentNullException(nameof(message));
|
||||
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(message);
|
||||
return Hash(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,7 +80,7 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Utilities
|
||||
if (ivBytes == null) throw new ArgumentNullException(nameof(ivBytes));
|
||||
if (ciperBytes == null) throw new ArgumentNullException(nameof(ciperBytes));
|
||||
|
||||
using RijndaelManaged aes = new RijndaelManaged();
|
||||
using var aes = Aes.Create();
|
||||
aes.KeySize = 256;
|
||||
aes.BlockSize = 128;
|
||||
aes.Mode = CipherMode.CBC;
|
||||
@@ -108,7 +108,7 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Utilities
|
||||
if (ivBytes == null) throw new ArgumentNullException(nameof(ivBytes));
|
||||
if (plainBytes == null) throw new ArgumentNullException(nameof(plainBytes));
|
||||
|
||||
using var aes = new RijndaelManaged();
|
||||
using var aes = Aes.Create();
|
||||
aes.KeySize = AES_KEY_SIZE;
|
||||
aes.BlockSize = AES_BLOCK_SIZE;
|
||||
//aes.Padding = PaddingMode.PKCS7;
|
||||
@@ -237,7 +237,7 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Utilities
|
||||
set.Add(sMsgEncrypt);
|
||||
|
||||
string rawText = string.Join(string.Empty, set.ToArray());
|
||||
string signText = Security.SHA1Utility.Hash(rawText);
|
||||
string signText = Utilities.SHA1Utility.Hash(rawText);
|
||||
return signText.ToLower();
|
||||
}
|
||||
|
||||
@@ -269,7 +269,7 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Utilities
|
||||
try
|
||||
{
|
||||
XmlDocument xmlDoc = new XmlDocument();
|
||||
xmlDoc.XmlResolver = null;
|
||||
xmlDoc.XmlResolver = null!;
|
||||
xmlDoc.LoadXml(xml);
|
||||
|
||||
XmlNode? xmlRoot = xmlDoc.FirstChild;
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI
|
||||
/// <summary>
|
||||
/// 一个微信智能对话平台接入 API HTTP 客户端。
|
||||
/// </summary>
|
||||
public class WechatOpenAIPlatformClient : CommonClientBase, IWechatClient
|
||||
public class WechatOpenAIPlatformClient : CommonClientBase, ICommonClient
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取当前客户端使用的微信智能对话平台凭证。
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI
|
||||
/// <summary>
|
||||
/// 表示微信智能对话平台接入 API 请求的基类。
|
||||
/// </summary>
|
||||
public abstract class WechatOpenAIPlatformRequest : IWechatRequest
|
||||
public abstract class WechatOpenAIPlatformRequest : ICommonRequest
|
||||
{
|
||||
public static class Serialization
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI
|
||||
/// <summary>
|
||||
/// 表示微信智能对话平台接入 API 响应的基类。
|
||||
/// </summary>
|
||||
public abstract class WechatOpenAIPlatformResponse : IWechatResponse
|
||||
public abstract class WechatOpenAIPlatformResponse : ICommonResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取原始的 HTTP 响应状态码。
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI
|
||||
/// <summary>
|
||||
/// 一个微信智能对话第三方接入 API HTTP 客户端。
|
||||
/// </summary>
|
||||
public class WechatOpenAIThirdPartyClient : CommonClientBase, IWechatClient
|
||||
public class WechatOpenAIThirdPartyClient : CommonClientBase, ICommonClient
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取当前客户端使用的微信智能对话平台凭证。
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI
|
||||
/// <summary>
|
||||
/// 表示微信智能对话第三方接入 API 请求的基类。
|
||||
/// </summary>
|
||||
public abstract class WechatOpenAIThirdPartyRequest : IWechatRequest
|
||||
public abstract class WechatOpenAIThirdPartyRequest : ICommonRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置请求超时时间(单位:毫秒)。如果不指定将使用构造 <see cref="WechatOpenAIPlatformClient"/> 时的 <see cref="WechatOpenAIPlatformClientOptions.Timeout"/> 参数,这在需要指定特定耗时请求(比如上传或下载文件)的超时时间时很有用。
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI
|
||||
/// <summary>
|
||||
/// 表示微信智能对话第三方接入 API 响应的基类。
|
||||
/// </summary>
|
||||
public abstract class WechatOpenAIThirdPartyResponse : IWechatResponse
|
||||
public abstract class WechatOpenAIThirdPartyResponse : ICommonResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取原始的 HTTP 响应状态码。
|
||||
|
||||
Reference in New Issue
Block a user