public static string Std_Encrypt_MD5(string AppKey)
        {
            MD5 MD5 = new MD5CryptoServiceProvider();
            byte[] datSource = Encoding.GetEncoding("gb2312").GetBytes(AppKey);
            byte[] newSource = MD5.ComputeHash(datSource);
            Console.WriteLine(newSource.Length);
            StringBuilder sb = new StringBuilder(32);
            for (int i = 0; i < newSource.Length; i++)
            {

                sb.Append(newSource[i].ToString("x").PadLeft(2, '0'));//ToString("x")是吧相应的字节转换为16进制的  PadLeft是在转换后只有一个数字的比如(a(十进制的10)左边添加一个0) 
            }
            string crypt = sb.ToString();
            Console.WriteLine(crypt.Length);
            return crypt;
        }

 

 posted on 2012-04-18 15:42  纳米程序员  阅读(183)  评论(0编辑  收藏  举报