在.NETCore中替换CryptoConfig类有什么用?

tus*_*309 1 .net c# cryptography .net-core

目前我在我的UWP应用程序中这样做

byte[] bytes = new UTF8Encoding().GetBytes(Password);
byte[] hash = ((HashAlgorithm)CryptoConfig.CreateFromName("MD5")).ComputeHash(bytes);
string hashstring = BitConverter.ToString(hash);
Run Code Online (Sandbox Code Playgroud)

我搜索了很多,但在.NETCore中找不到CryptoConfig类的替代品.

Jon*_*eet 5

看起来你根本不需要CryptoConfig.你只需要MD5:

using (var md5 = MD5.Create())
{
    var hash = md5.ComputeHash(Encoding.UTF8.GetBytes(password));
    return BitConverter.ToString(hash);
}
Run Code Online (Sandbox Code Playgroud)

MD5类存在于netstandard1.3和更高.