/// <summary> /// 计算md5 /// </summary> /// <param name="str"></param> /// <returns></returns> private string CalcMD5(string str) { byte[] buffer = Encoding.UTF8.GetBytes(str); using (MD5 md5 = MD5.Create()) { byte[] md5Bytes = md5.ComputeHash(buffer); StringBuilder sb = new StringBuilder(); for (int i = 0; i < md5Bytes.Length; i++) { sb.Append(md5Bytes[i].ToString("x2"));//X2时,生成字母大写MD5 } return sb.ToString(); } }