private string MD5Info(string baseText)
{
//第一种方法。
var sbInfo = new StringBuilder();
sbInfo.AppendFormat("{0}===",FormsAuthentication.HashPasswordForStoringInConfigFile(baseText,"MD5"));
//第二种方法。
var hashvalue = (new MD5CryptoServiceProvider()).ComputeHash(Encoding.UTF8.GetBytes(baseText));
return sbInfo.AppendFormat("{0}", BitConverter.ToString(hashvalue).Replace("-", string.Empty)).ToString();
}
本文介绍了两种使用MD5进行字符串加密的方法:一种是利用FormsAuthentication的HashPasswordForStoringInConfigFile方法,另一种是通过创建MD5CryptoServiceProvider实例并结合UTF-8编码实现。
1万+

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



