我有一个 ASP.NET 5 RC1(即将成为 ASP.NET Core)Web 应用程序项目。
它需要计算 SHA1 哈希值。
各种 SHA1
子类在 DNX 4.5.1 下可用并构建,但在 DNX Core 5.0 下似乎没有任何可用的实现。
我是否必须添加引用才能引入该代码,还是它根本不适用于 .NET Core?
根据 this article :
.NET Core consists of a set of libraries, called “CoreFX”, and a small, optimized runtime, called “CoreCLR”.
果然,在CoreFX repo中,没有
SHA1
的子类:https://github.com/dotnet/corefx/tree/master/src/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography
然而,在 CoreCLR 中,子类如您所料,在 mscorlib 中:
https://github.com/dotnet/coreclr/tree/43b39a73cbf832ec13ec29ed356cb75834e7a8d7/src/mscorlib/src/System/Security/Cryptography
为什么 coreclr 和 corefx 之间存在重叠?此 mscorlib 代码是否不适用于 .NET Core 项目?
System.Security.Crytpography.Algorithms
package on NuGet的说明说:Provides base types for cryptographic algorithms, including hashing, encryption, and signing operations.
是否有另一个包含实际算法而不仅仅是基类的包?这是尚未移植的东西吗?有什么地方可以像 Mono 那样查看 API 的状态和路线图吗?
最佳答案
添加 System.Security.Cryptography.Algorithms
nuget 包。
然后
var sha1 = System.Security.Cryptography.SHA1.Create();
var hash = sha1.ComputeHash(myByteArray)
关于.net - 使用 ASP.NET Core 计算 SHA1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35363358/