using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace HcgClientExport { public class En { public static string GenerateMD5(string txt) { using (System.Security.Cryptography.MD5 mi = System.Security.Cryptography.MD5.Create()) { byte[] buffer = Encoding.Default.GetBytes(txt); //开始加密 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(); } } } }