diff --git a/AgileConfig.Server.Common/Encrypt.cs b/AgileConfig.Server.Common/Encrypt.cs new file mode 100644 index 00000000..6690345f --- /dev/null +++ b/AgileConfig.Server.Common/Encrypt.cs @@ -0,0 +1,17 @@ +using System; +using System.Security.Cryptography; +using System.Text; + +namespace AgileConfig.Server.Common +{ + public static class Encrypt + { + private static readonly MD5 Md5Instance = MD5.Create(); + public static string Md5(string txt) + { + var inputBytes = Encoding.ASCII.GetBytes(txt); + var hashBytes = Md5Instance.ComputeHash(inputBytes); + return Convert.ToHexString(hashBytes); + } + } +} diff --git a/AgileConfig.Server.Common/encrypt.cs b/AgileConfig.Server.Common/encrypt.cs deleted file mode 100644 index 9745ccb9..00000000 --- a/AgileConfig.Server.Common/encrypt.cs +++ /dev/null @@ -1,27 +0,0 @@ -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(); - } - } - } -}