类库需要使用md5加密方法
//需要的命名空间
using System.Security.Cryptography;
public string Encryption(string pwd)
{
MD5 md5 = MD5.Create();
StringBuilder builder = new StringBuilder();
byte[] md5Bytes = md5.ComputeHash(Encoding.UTF8.GetBytes(pwd));
for (int i = 0; i < md5Bytes.Length; i++)
{
builder.AppendFormat("{0:X2}", md5Bytes[i]);
}
return builder.ToString();
}
----------------------------------------------------------------------------------------------------------
web Form 使用md5 加密方法
//需要的命名空间
using System.Web.Security;
public string Encryption(string pwd)
{
System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(pwd, "MD5").ToUpper();
}
最后
以上就是复杂红牛最近收集整理的关于使用MD5加密的全部内容,更多相关使用MD5加密内容请搜索靠谱客的其他文章。
发表评论 取消回复