【 tulaoshi.com - ASP.NET 】
public static string HashCryptString(string strText,string method){
if(method == "MD5"){
strText = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(strText,"MD5");
// MD5 md5 = new MD5CryptoServiceProvider();
// strText = System.Text.Encoding.UTF8.GetString(md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(strText)));
}
else if(method == "SHA1"){
strText = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(strText,"SHA1");
// SHA1 sha1 = new SHA1CryptoServiceProvider();
// strText = System.Text.Encoding.UTF8.GetString(sha1.ComputeHash(System.Text.Encoding.UTF8.GetBytes(strText)));
}
return strText;
}