C# MD5
加密的几种方法
管理提醒:
本帖被
gaolei2016
执行加亮操作
(2010-01-21)
MD5
加密是在网站开发经常使用到的加密方案。
在这里介绍几种
MD5
的几种方法。
1
、
asp.net
中,
MS
有一套专用的加密使用方法:
/// code
为加密位数,
16
和
32
public static string Md5(string str, int code)
{
//str = System.Web.HttpUtility.UrlEncode(str);
if (code == 16) //16
位
MD5
加密(取
32
位加密的
9~25
字符)
{
return
System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str,
"MD5").ToLower().Substring(8, 16);
}
else//32
位加密
{
return
System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str,
"MD5").ToLower();
}
http://wenku.baidu.com/view/bcd3363143323968011c9223.html这里有详细的说明,
导入命名空间后 直接调用就好了. 但是不能还原回来哟.