using System; using System.Collections.Generic; using System.Security.Cryptography; using System.Text; namespace AgileConfig.Server.Common { public class Encrypt { public static string Md5(string txt) { using (var md5 = MD5.Create()) { var inputBytes = Encoding.ASCII.GetBytes(txt); var hashBytes = md5.ComputeHash(inputBytes); // Convert the byte array to hexadecimal string var sb = new StringBuilder(); for (var i = 0; i < hashBytes.Length; i++) { sb.Append(hashBytes[i].ToString("X2")); } return sb.ToString(); } } } }