.NET 8 - 我的平台不支持 SHA3.NET 8 - SHA3 not supported on my platform

.NET 8 - SHA3 not supported on my platform

提问人:Bird2 提问时间:11/17/2023 更新时间:11/17/2023 访问量:57

问:

我在 .NET 8 上创建了一个新项目来尝试所有新功能。其中之一是SHA3,但是,由于某些原因,我的平台不支持SHA3。我没有在任何虚拟机上运行它,我在 Windows 11 x64 处理器 AMD Ryzen 3 5300U 上运行。

当我尝试使用任何 SHA3 类或任何 Shake 算法类时,我会得到一个异常,告诉我我的平台不支持该操作。我可以在不需要其他一些外部库的情况下以某种方式修复它吗?

using System.Security.Cryptography;

var hash = SHA3_256.HashData("Example data to hash"u8);
Unhandled exception. System.PlatformNotSupportedException: Operation is not supported on this platform.
   at System.Security.Cryptography.SHA3_256.TryHashData(ReadOnlySpan`1 source, Span`1 destination, Int32& bytesWritten)
   at System.Security.Cryptography.SHA3_256.HashData(ReadOnlySpan`1 source, Span`1 destination)
   at System.Security.Cryptography.SHA3_256.HashData(ReadOnlySpan`1 source)
   at Program.<Main>$(String[] args) in C:\Users\admin\source\repos\Net8Test\Net8Test\Program.cs:line 3

谢谢。

C# .net

评论

0赞 Magnus 11/17/2023
根据 learn.microsoft.com/en-us/dotnet/standard/security/...:“.NET 8 引入了对 SHA-3 哈希算法的支持,包括 SHAKE-128 和 SHAKE-256。目前,Windows 11 build 25324 或更高版本以及具有 OpenSSL 1.1.1 或更高版本的 Linux 支持 SHA-3。
0赞 Bird2 11/17/2023
我明白了,你知道它什么时候可用于所有版本吗?或者我可以将 Windows 升级到该版本(我在 Insider Preview 上)?
0赞 Magnus 11/17/2023
也许您可以使用第三方库 nuget.org/packages/SHA3.Net
0赞 Bird2 11/17/2023
虽然我不喜欢这种小事情的第三方库解决方案,但除了第三方库之外,没有其他方法可以在我的平台上使用 SHA3。无论如何,感谢您的链接和解释。
0赞 nd_ 12/17/2023
嗯......同样的问题在这里。我已经安装了最新的 Windows 11 更新,但仍然不支持 SHA3(Windows 版本低于支持的版本)。我使用 Bouncy Castle 作为后备,希望很快就会有另一个 Windows 更新......

答: 暂无答案