ASP.Net中的MD5加密

王朝asp·作者佚名  2008-05-31
宽屏版  字体: |||超大  

其实在ASP.Net编程中,不用调用md5.asp来加密数据。在DotNet中有自带的类:System.Web.Security.HashPasswordForStoringInConfigFile()

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) ;

}

if(code==32) //32位加密

{

return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str,"MD5").ToLower();

}

return "00000000000000000000000000000000";

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有