mirror of
https://github.com/dotnetcore/AgileConfig.git
synced 2026-10-24 17:20:14 +08:00
28 lines
748 B
C#
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();
|
|
}
|
|
}
|
|
}
|
|
}
|