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

10
我正在使用新版本的ASP.NET MVC 6(ASP.NET 5)。如果我针对.NET CoreCLR框架(ASP.NET Core),由于我正在使用来自System.Security.Cryptography的MD5CryptoServiceProvider,代码无法编译。您能否建议任何与CoreCLR框架兼容的替代品?
3个回答

12

使用 MD5.Create() 来自 System.Security.Cryptography.Hashing.Algorithms System.Security.Cryptography.Algorithms 包。

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


你好,dotnet core 中是否有 System.Security.Cryptography.ICryptoTransform 的 MD5 实现可供与 CryptoStream 一起使用?我想要读取一个流,并将其写入多个流中,包括增量计算哈希流... - Dede
找到了:System.Security.Cryptography.IncrementalHash.Create(HashAlgorithmName.MD5) - Dede

6

更新至Victor Hurdugaci的答案:使用System.Security.Cryptography.Algorithms包。

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

提示


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();
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接