请注意是16位的

解决方案 »

  1.   

    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) ;

    else//32位加密
    {
    return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str,"MD5").ToLower();

    }调用
    pwd=MD5(pwd,16)
    pwd=MD5(pwd,32)
      

  2.   

    public string MD5(string ToEncryptString)
    {
    MD5CryptoServiceProvider hashmd5;
    hashmd5 = new MD5CryptoServiceProvider();
    return BitConverter.ToString(hashmd5.ComputeHash(System.Text.Encoding.Default.GetBytes(ToEncryptString))).Replace("-","").ToLower().Substring(8,16);//把所有字符变小写
    }也可以
      

  3.   

    using System.Security.Cryptography;