MemoryStream ms = new MemoryStream();
            bmpp.Save(ms, ImageFormat.Bmp);            byte[] buffer = new byte[ms.Length];
            ms.Read(buffer, 0, buffer.Length);
            vstr = GetMD5(Encoding.ASCII.GetString(buffer));
            ms.Close();为什么这样的代码得到的md5值都是一样的

解决方案 »

  1.   

     private string GetMD5(string str)
            {
                return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5");
            }
      

  2.   

    //获取byte数组中指定部分的MD5码 public static string CreateMD5(byte[] buffer, int offset, int count)
            {
                MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
                byte[] hash = md5.ComputeHash(buffer, offset, count);
                return ByteArrayToHexString(hash);
            }        private static string ByteArrayToHexString(byte[] values)
            {
                StringBuilder sb = new StringBuilder();
                foreach (byte value in values)
                {
                    sb.AppendFormat("{0:X2}", value);
                }
                return sb.ToString();
    }
      

  3.   

    求md5这步没问题,只是不知道为什么md5的值求不出来
    获得的buffer永远是0