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

时间:2014-11-30 17:35:26

标签: asp.net-core .net-core

我正在使用新版本的ASP.NET MVC 6(ASP.NET 5)。如果我的目标是.NET CoreCLR框架(ASP.NET Core),则代码无法编译,因为我使用MD5CryptoServiceProvider中的System.Security.Cryptography。您能否建议使用CoreCLR框架编译的任何替代方案?

3 个答案:

答案 0 :(得分:12)

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

<强>更新 System.Security.Cryptography.Hashing.Algorithms目前已被标记为过时。

答案 1 :(得分:6)

更新至Victor Hurdugaci's answer:使用包System.Security.Cryptography.Algorithms

System.Security.Cryptography.Hashing.Algorithms目前已被标记为过时。

hint

答案 2 :(得分: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();
}
相关问题