mirror of
https://github.com/nsnail/ns-ext.git
synced 2025-07-02 08:08:15 +08:00
@ -1,5 +1,6 @@
|
||||
global using System;
|
||||
global using System.ComponentModel;
|
||||
global using System.Diagnostics;
|
||||
global using System.Globalization;
|
||||
global using System.Text;
|
||||
global using System.Text.RegularExpressions;
|
||||
|
@ -1,8 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0"/>
|
||||
<PackageReference Include="xunit" Version="2.8.1"/>
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0"/>
|
||||
<PackageReference Include="xunit" Version="2.9.2"/>
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0-pre.49">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
|
@ -258,10 +258,13 @@ public static class StringExtensions
|
||||
#pragma warning disable CA5350
|
||||
using var hmacSha1 = new HMACSHA1(e.GetBytes(secret));
|
||||
#pragma warning restore CA5350
|
||||
|
||||
#if NET9_0_OR_GREATER
|
||||
return Convert.ToHexStringLower(hmacSha1.ComputeHash(e.GetBytes(me)));
|
||||
#else
|
||||
return BitConverter.ToString(hmacSha1.ComputeHash(e.GetBytes(me)))
|
||||
.Replace("-", string.Empty)
|
||||
.ToLower(CultureInfo.CurrentCulture);
|
||||
.Replace("-", string.Empty)
|
||||
.ToLower(CultureInfo.CurrentCulture);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -405,10 +408,14 @@ public static class StringExtensions
|
||||
public static string Md5(this string me, Encoding e)
|
||||
{
|
||||
#pragma warning disable CA5351
|
||||
#if NET9_0_OR_GREATER
|
||||
return Convert.ToHexStringLower(MD5.HashData(e.GetBytes(me)));
|
||||
#else
|
||||
return BitConverter.ToString(MD5.HashData(e.GetBytes(me)))
|
||||
#pragma warning restore CA5351
|
||||
.Replace("-", string.Empty)
|
||||
.ToLower(CultureInfo.CurrentCulture);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -490,10 +497,14 @@ public static class StringExtensions
|
||||
public static string Sha1(this string me, Encoding e)
|
||||
{
|
||||
#pragma warning disable CA5350
|
||||
#if NET9_0_OR_GREATER
|
||||
return Convert.ToHexStringLower(SHA1.HashData(e.GetBytes(me)));
|
||||
#else
|
||||
return BitConverter.ToString(SHA1.HashData(e.GetBytes(me)))
|
||||
#pragma warning restore CA5350
|
||||
.Replace("-", string.Empty)
|
||||
.ToLower(CultureInfo.CurrentCulture);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -606,9 +617,13 @@ public static class StringExtensions
|
||||
#pragma warning disable CA5351
|
||||
using var md5Hmac = new HMACMD5(e.GetBytes(key));
|
||||
#pragma warning restore CA5351
|
||||
#if NET9_0_OR_GREATER
|
||||
return Convert.ToHexStringLower(md5Hmac.ComputeHash(e.GetBytes(me)));
|
||||
#else
|
||||
return BitConverter.ToString(md5Hmac.ComputeHash(e.GetBytes(me)))
|
||||
.Replace("-", string.Empty)
|
||||
.ToLower(CultureInfo.CurrentCulture);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#pragma warning restore CodeLinesAnalyzer
|
@ -7,7 +7,7 @@
|
||||
<Import Project="$(SolutionDir)/build/copy.pkg.xml.comment.files.targets"/>
|
||||
<Import Project="$(SolutionDir)/build/prebuild.targets"/>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0"/>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Update="*.json">
|
||||
|
Reference in New Issue
Block a user