ASP.Net中的MD5加密

[入库:2005年8月18日] [更新:2007年3月25日]

本文简介:选择自 catally 的 blog

其实在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";
  }

本文关键:ASP.Net中的MD5加密
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top