复制代码 代码如下:
Response.Write(FormsAuthentication.HashPasswordForStoringInConfigFile("www.mzwu.com", "MD5"));
//结果:D66E1F138689B9B5AA4C520D9EAFFB61
复制代码 代码如下:
Response.Write(MD5("www.mzwu.com",32))
'结果:d66e1f138689b9b5aa4c520d9eaffb61
复制代码 代码如下:
Response.Write(FormsAuthentication.HashPasswordForStoringInConfigFile("木子屋", "MD5"));
//结果:34D9CBD5164C47058DFA3AF832E2D1DC
复制代码 代码如下:
Response.Write(MD5("木子屋",32))
'结果:0a40a90190da023ae7aa17771663a41e
复制代码 代码如下:
MD5CryptoServiceProvider MD5 = new MD5CryptoServiceProvider();
Response.Write(BitConverter.ToString(MD5.ComputeHash(Encoding.GetEncoding("gb2312").GetBytes("木子屋"))).Replace("-", ""));
//结果:0A40A90190DA023AE7AA17771663A41E
复制代码 代码如下:
MD5CryptoServiceProvider MD5 = new MD5CryptoServiceProvider();
Response.Write(BitConverter.ToString(MD5.ComputeHash(Encoding.GetEncoding("utf-8").GetBytes("木子屋"))).Replace("-", ""));
//结果:34D9CBD5164C47058DFA3AF832E2D1DC
复制代码 代码如下:
/**//// <summary>
/// 对字符串进行MD5加密
/// </summary>
/// <param>要加密的字符串</param>
/// <param>字符串编码格式</param>
/// <example>str = MD5("木子屋","gb2312");</example>
/// <returns></returns>
public string MD5(string text, string charset)
{
return (MD5(text, charset, false));
}
/**//// <summary>
/// 对字符串或参数值进行MD5加密
/// </summary>
/// <param>要加密的字符串或参数名称</param>
/// <param>字符串编码格式</param>
/// <param>加密字符串类型 true:参数值 false:字符串</param>
/// <returns></returns>
public string MD5(string text, string charset, bool isArg)
{
try
{
MD5CryptoServiceProvider MD5 = new MD5CryptoServiceProvider();
if (isArg)
{
NameValueCollection Collect = HttpUtility.ParseQueryString(Request.Url.Query, Encoding.GetEncoding(charset));//使用Collect接收参数值
if (Collect[text] != null)
{
return BitConverter.ToString(MD5.ComputeHash(Encoding.GetEncoding(charset).GetBytes(Collect[text].ToString()))).Replace("-", "");
}
}
else
{
return BitConverter.ToString(MD5.ComputeHash(Encoding.GetEncoding(charset).GetBytes(text))).Replace("-", "");
}
}
catch { }
return string.Empty;
}
复制代码 代码如下:
using System.Text;
using System.Web.Security;
using System.Security.Cryptography;
using System.Collections.Specialized;
新闻热点
疑难解答
图片精选