public string md5(string str,int code)
{
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();
}
} MD5加密使用
最新推荐文章于 2020-12-14 16:43:43 发布
本文介绍了一个使用C#实现的MD5加密方法,该方法能够根据参数选择生成16位或32位的MD5加密字符串。通过FormsAuthentication的HashPasswordForStoringInConfigFile方法完成加密过程,并提供了一个简单的条件判断来决定返回的加密字符串长度。
2万+

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



