21 lines
587 B
C#
21 lines
587 B
C#
using System.Security.Cryptography;
|
|
using System.Text;
|
|
|
|
namespace IRaCIS.Core.Infrastructure
|
|
{
|
|
public class MD5Helper
|
|
{
|
|
public static string Md5(string target)
|
|
{
|
|
using (MD5 md5 = MD5.Create())
|
|
{ // MD5非线程安全
|
|
byte[] bytes = md5.ComputeHash(Encoding.UTF8.GetBytes(target));
|
|
StringBuilder sb = new StringBuilder(32);
|
|
for (int i = 0; i < bytes.Length; ++i)
|
|
sb.Append(bytes[i].ToString("x2"));
|
|
return sb.ToString();
|
|
}
|
|
}
|
|
}
|
|
}
|