Files
2020-03-29 01:27:51 +08:00

28 lines
748 B
C#

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();
}
}
}
}