其實在.Net 有一個最簡單實現MD5的方法
<summary>
/// MD5加密
/// </summary>
/// <param name="toCryString">被加密字符串</param>
/// <returns>加密後的字符串</returns>
public static string MD5(string toCryString)
{
return FormsAuthentication.HashPassWordForStoringInConfigFile(toCryString, "MD5");
}
方法2:
public static string MD5(string str)
{
MD5 md5 = new MD5CryptoServiceProvider();
byte[] result = md5.ComputeHash(System.Text.Encoding.Default.GetBytes(str));
string str2 = "";
for(int i=0;i<result.Length;i++)
{
str2 += string.Format("{0:x}",result[i]);
}
return str2;
}
鏈接地址: http://dygstudio.cnblogs.com/archive/2006/07/13/449988.Html