用ASP.Net中的自带类进行MD5加密


其实在ASP.net编程中,不用调用md5.asp来加密数据。在DotNet中有自带的类:System.Web.Security.HashPasswordForStoringInConfigFile()
以下是引用片段:
publicstringmd5(stringstr,intcode) 
{ 
if(code==16)//16位MD5加密(取32位加密的9~25字符) 
{ 
returnSystem.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str,"MD5").ToLower().Substring(8,16); 
} 
if(code==32)//32位加密 
{ 
returnSystem.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str,"MD5").ToLower(); 
} 
return"00000000000000000000000000000000"; 
}
« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3