public static string UseMd5(string str) { using (MD5 mi = MD5.Create()) { byte[] buffer = Encoding.Default.GetBytes(str.Trim()); //开始加密 byte[] newBuffer = mi.ComputeHash(buffer); StringBuilder sb = new StringBuilder(); for (int i = 0; i < newBuffer.Length; i++) { sb.Append(newBuffer[i].ToString("x2")); } return sb.ToString(); } }