博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

C# MD5 加密方法 16位或32位

Posted on 2007-07-11 10:34  孤峰皓月  阅读(1818)  评论(3编辑  收藏  举报
 1public string md5(string str,int code) 
 2
 3    if(code==16//16位MD5加密(取32位加密的9~25字符) 
 4    
 5        return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str,"MD5").ToLower().Substring(8,16) ; 
 6    }
  
 7    else//32位加密 
 8    
 9        return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str,"MD5").ToLower(); 
10    }
  
11}
 
12