Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 "asdasd" match. (http://www.fileformat.info/tool/hash.htm?text=asdasd)

like image 957
Lazlo Avatar asked Sep 13 '09 23:09

Lazlo


1 Answers

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();
}
like image 113
The Matt Avatar answered Oct 12 '22 14:10

The Matt