Skip to content

Instantly share code, notes, and snippets.

@huanlin
Created September 12, 2013 15:46
Show Gist options
  • Save huanlin/6539743 to your computer and use it in GitHub Desktop.
Save huanlin/6539743 to your computer and use it in GitHub Desktop.
System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile() is obsoleted, use MD5 class instead.
string MD5Hash(string str)
{
// return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(pwd);
var md5 = MD5.Create();
var hashedBytes = md5.ComputeHash(Encoding.UTF8.GetBytes(str));
var hashedStr = String.Join("", hashedBytes.Select(x => x.ToString("x2")));
return hashedStr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment