MD5CryptoServiceProvider in ASP.NET Core
<p>I have a database with passwords created in the old Identity system. Passwords were hashed using the <code>MD5CryptoServiceProvider</code> class. I now need to use these passwords in ASP.NET MVC Core but <code>MD5CryptoServiceProvider</code> doesn't exist.</p>

<p>In .NET Framework the function I used to compute the hashes is:</p>

<pre><code>public static string CreateHash(string unHashed)
{
    var x = new System.Security.Cryptography.MD5CryptoServiceProvider();
    var data = Encoding.ASCII.GetBytes(unHashed);
    data = x.ComputeHash(data);
    return Encoding.ASCII.GetString(data);
}
</code></pre>

<p>I've tried the following two functions in ASP.NET Core:</p>

<pre><code>public static string CreateHash(string unHashed)
{
    var x = new System.Security.Cryptography.HMACMD5();
    var data = Encoding.ASCII.GetBytes(unHashed);
    data = x.ComputeHash(data);
    return Encoding.ASCII.GetString(data);
}
</code></pre>

<p>and</p>

<pre><code>public static string MD5Hash(string input)
{
    using (var md5 = MD5.Create())
    {
        var result = md5.ComputeHash(Encoding.ASCII.GetBytes(input));
        var strResult = BitConverter.ToString(result);
        return strResult.Replace("-", "");
    }
}
</code></pre>

<p>Neither method returns the same string that <code>MD5CryptoServiceProvider</code> class does in the first method. I can't change the entire database to use new passwords.</p>

<p>Any fix to this?</p>