首次提交:本地项目同步到Gitea
This commit is contained in:
32
Cowain.Base/Helpers/Md5Helper.cs
Normal file
32
Cowain.Base/Helpers/Md5Helper.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user