适配net10

This commit is contained in:
2248356998 qq.com
2025-09-28 13:06:39 +08:00
parent 3c9e397403
commit 976323a716
5 changed files with 12 additions and 7 deletions

View File

@@ -35,7 +35,7 @@ public static class PBKDF2Encryption
var salt = new byte[saltSize]; var salt = new byte[saltSize];
rng.GetBytes(salt); rng.GetBytes(salt);
#if NET10_0_OR_GREATER #if NET10_0_OR_GREATER
var hash = Rfc2898DeriveBytes.Pbkdf2(Encoding.UTF8.GetBytes(text), salt, iterationCount, HashAlgorithmName.SHA256, derivedKeyLength); var hash = Rfc2898DeriveBytes.Pbkdf2(System.Text.Encoding.UTF8.GetBytes(text), salt, iterationCount, HashAlgorithmName.SHA256, derivedKeyLength);
#else #else
using var pbkdf2 = new Rfc2898DeriveBytes(text, salt, iterationCount, HashAlgorithmName.SHA256); using var pbkdf2 = new Rfc2898DeriveBytes(text, salt, iterationCount, HashAlgorithmName.SHA256);
var hash = pbkdf2.GetBytes(derivedKeyLength); var hash = pbkdf2.GetBytes(derivedKeyLength);
@@ -69,7 +69,7 @@ public static class PBKDF2Encryption
return false; return false;
#if NET10_0_OR_GREATER #if NET10_0_OR_GREATER
var computedHash = Rfc2898DeriveBytes.Pbkdf2(Encoding.UTF8.GetBytes(text), saltBytes, iterationCount, HashAlgorithmName.SHA256, derivedKeyLength); var computedHash = Rfc2898DeriveBytes.Pbkdf2(System.Text.Encoding.UTF8.GetBytes(text), saltBytes, iterationCount, HashAlgorithmName.SHA256, derivedKeyLength);
#else #else
using var pbkdf2 = new Rfc2898DeriveBytes(text, saltBytes, iterationCount, HashAlgorithmName.SHA256); using var pbkdf2 = new Rfc2898DeriveBytes(text, saltBytes, iterationCount, HashAlgorithmName.SHA256);
var computedHash = pbkdf2.GetBytes(derivedKeyLength); var computedHash = pbkdf2.GetBytes(derivedKeyLength);

View File

@@ -1,9 +1,9 @@
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<PluginVersion>10.11.76</PluginVersion> <PluginVersion>10.11.77</PluginVersion>
<ProPluginVersion>10.11.76</ProPluginVersion> <ProPluginVersion>10.11.77</ProPluginVersion>
<DefaultVersion>10.11.76</DefaultVersion> <DefaultVersion>10.11.77</DefaultVersion>
<AuthenticationVersion>10.11.6</AuthenticationVersion> <AuthenticationVersion>10.11.6</AuthenticationVersion>
<SourceGeneratorVersion>10.11.6</SourceGeneratorVersion> <SourceGeneratorVersion>10.11.6</SourceGeneratorVersion>
<NET8Version>8.0.20</NET8Version> <NET8Version>8.0.20</NET8Version>

View File

@@ -14,7 +14,7 @@
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="xunit" Version="2.9.3" /> <PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.4"> <PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>

View File

@@ -12,6 +12,11 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
#if NET10_0_OR_GREATER
using Microsoft.Extensions.Hosting;
#endif
using MQTTnet.AspNetCore; using MQTTnet.AspNetCore;
using ThingsGateway.Foundation; using ThingsGateway.Foundation;

View File

@@ -42,7 +42,7 @@ public partial class MqttServer : BusinessBaseWithCacheIntervalScriptAll
#if NET10_0_OR_GREATER #if NET10_0_OR_GREATER
private IHost _webHost { get; set; } private Microsoft.Extensions.Hosting.IHost _webHost { get; set; }
#else #else
private IWebHost _webHost { get; set; } private IWebHost _webHost { get; set; }