tushargoyal1309
tushargoyal1309

Reputation: 175

What is the replacement of CryptoConfig class in .NETCore?

Currently i am doing this in my UWP app

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

I have searched a lot but couldn't find the replacement of CryptoConfig class in .NETCore.

Upvotes: 1

Views: 815

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1500903

It looks like you don't need CryptoConfig at all. You just need MD5:

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

The MD5 class is present in netstandard1.3 and higher.

Upvotes: 5

Related Questions