Skip to content

Instantly share code, notes, and snippets.

@ChrisMcKee
Created January 4, 2013 13:49
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChrisMcKee/4452722 to your computer and use it in GitHub Desktop.
Save ChrisMcKee/4452722 to your computer and use it in GitHub Desktop.
PHP MD5 Hash in C# Most implementations of the PHP md5() function in C# produce a different result; this produces the correct one.
public static string PHPMd5Hash(string pass)
{
using (MD5 md5 = MD5.Create())
{
byte[] input = Encoding.UTF8.GetBytes(pass);
byte[] hash = md5.ComputeHash(input);
return BitConverter.ToString(hash).Replace("-", "");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment