Files
WCS/Cowain.Base/Helpers/Md5Helper.cs
2026-03-02 09:08:20 +08:00

33 lines
794 B
C#

using System.Security.Cryptography;
using System.Text;
namespace Cowain.Base.Helpers;
public static class Md5Helper
{
/// <summary>
/// 32bit UTF8 MD5 Encrypt
/// </summary>
/// <param name="plaintext">明文</param>
/// <returns></returns>
public static string Md5Encrypt32(string plaintext)
{
string pwd = string.Empty;
if (!string.IsNullOrEmpty(plaintext) && !string.IsNullOrWhiteSpace(plaintext))
{
using (MD5 md5 = MD5.Create())
{
byte[] s = md5.ComputeHash(Encoding.UTF8.GetBytes(plaintext));
foreach (var item in s)
{
pwd = string.Concat(pwd, item.ToString("x2"));
}
}
}
return pwd;
}
}