CoreCLR(ASP.NET 5 Core)中MD5CryptoServiceProvider的替代方案

Nik*_*tov 8 .net-core asp.net-core

我正在使用新版本的ASP.NET MVC 6(ASP.NET 5).如果我面向.NET框架CoreCLR(ASP.NET核心)的代码不会编译,因为我使用MD5CryptoServiceProviderSystem.Security.Cryptography.您能否建议使用CoreCLR框架编译的任何替代方案?

Vic*_*aci 12

MD5.Create()从包中使用System.Security.Cryptography.Hashing.Algorithms. System.Security.Cryptography.Algorithms.

目前更新 System.Security.Cryptography.Hashing.Algorithms已标记为过时.


小智 6

更新Victor Hurdugaci的回答:使用包System.Security.Cryptography.Algorithms.

System.Security.Cryptography.Hashing.Algorithms 目前已经过时了.

暗示


Ded*_*ede 5

对于增量散列,在System.Security.Cryptography:

using (IncrementalHash hasher = IncrementalHash.CreateHash(HashAlgorithmName.MD5))
{
    //hash loop
    hasher.AppendData(data);
    hasher.AppendData(data);
    hasher.AppendData(data);


    byte[] hash = hasher.GetHashAndReset();
}
Run Code Online (Sandbox Code Playgroud)