MD5加密

WinForm:
public   string  GetMD5( string  str)
{
    
byte [] b  =  System.Text.Encoding.Default.GetBytes(str);
    b 
=   new  System.Security.Cryptography.MD5CryptoServiceProvider().ComputeHash(b);
    StringBuilder sb 
=   new  StringBuilder( 64 );
    
foreach  ( byte  bs  in  b)
    {
        sb.AppendFormat(
" {0:X2} " , bs);
    }
    
return  sb.ToString();
}
WebForm:
public   string  GetMD5( string  str)
{
    
return  System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(Password, " MD5 " );
}

你可能感兴趣的:(MD5加密)