How can I reproduce a SHA512 hash in C# that fits the PHP SHA512?

前端 未结 3 563
天涯浪人
天涯浪人 2021-01-05 05:02

The question is pretty much self-explanatory. I Googled many sites, many methods, tried many encodings, but I can\'t get it to match.

I\'m trying to make the string

3条回答
  •  星月不相逢
    2021-01-05 05:15

    Try this

    using System.Security.Cryptography
    
    public static string HashPassword(string unhashedPassword)
    {
        return BitConverter.ToString(new SHA512CryptoServiceProvider().ComputeHash(Encoding.Default.GetBytes(unhashedPassword))).Replace("-", String.Empty).ToUpper();
    }
    

提交回复
热议问题