您的位置:首页 > 编程语言 > C#

C#中Md5给密码加密

2012-03-06 11:09 239 查看
// 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();

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: