Commit 20ad23ac authored by 黄奎's avatar 黄奎

111

parent 2231c82f
......@@ -21,6 +21,7 @@ using System.Threading.Tasks;
using System.Web;
using Microsoft.Extensions.Hosting;
using System.Drawing;
using System.Security.Cryptography;
namespace Mall.Common
{
......@@ -833,5 +834,27 @@ namespace Mall.Common
}
}
/// <summary>
/// 获取hash值
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static string GetHash(string value)
{
string result = "";
using (var md5Hash = MD5.Create())
{
byte[] data = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(value));
StringBuilder builder = new StringBuilder();
for (int i = 0; i < data.Length; i++)
{
builder.Append(data[i].ToString("x2")); //使用小写字母表示每个字节的十六进制值
}
result = builder.ToString();
}
return result;
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment