MD5加密处理

//引用命名空间
using System.Web.Security;  
//MD5加密后长度是32位   
FormsAuthentication.HashPasswordForStoringInConfigFile("abc","md5")   
  
  
//SH1加密后长度是40位   
FormsAuthentication.HashPasswordForStoringInConfigFile("abc""sha1")  


//例子:
public string EncryptStr(string PWD, int Format)
    {
        
string str = "";
        
switch (Format)
        {
            
case 0:
                str 
= FormsAuthentication.HashPasswordForStoringInConfigFile(PWD, "SHA1");
                
break;
            
case 1:
                str 
= FormsAuthentication.HashPasswordForStoringInConfigFile(PWD, "MD5");
                
break;
        }
        
return str;
    }

 

posted @ 2009-09-27 16:15  韩天伟  阅读(349)  评论(0编辑  收藏  举报