winfrom:
public static string StringToMD5Hash(string inputString)
{
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
byte[] encryptedBytes = md5.ComputeHash(Encoding.ASCII.GetBytes(inputString));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < encryptedBytes.Length; i++)
{
sb.AppendFormat("{0:X2}", encryptedBytes[i]);
}
return sb.ToString();
}
web:
public static string MD5(string strSrc)
{
return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(strSrc, "md5");
}
.net web与winfrom程序的md5加密算法
最新推荐文章于 2022-06-26 15:03:14 发布
本文提供了两种实现字符串到MD5哈希的方法。一种是通过WinForm应用程序中的自定义函数完成,另一种则是利用Web开发中FormsAuthentication类提供的现成方法。

584

被折叠的 条评论
为什么被折叠?



