我正在使用新版本的ASP.NET MVC 6(ASP.NET 5)。如果我的目标是.NET CoreCLR框架(ASP.NET Core),则代码无法编译,因为我使用MD5CryptoServiceProvider
中的System.Security.Cryptography
。您能否建议使用CoreCLR框架编译的任何替代方案?
答案 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
目前已被标记为过时。
答案 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();
}