You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
771 B
31 lines
771 B
9 months ago
|
using System.Text;
|
||
|
using System.Security.Cryptography;
|
||
|
|
||
|
namespace FangYar.Common
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// MD5加密类
|
||
|
/// </summary>
|
||
|
public class Md5
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// MD5加密字符串
|
||
|
/// </summary>
|
||
|
public static string GetMD5String(string str)
|
||
|
{
|
||
|
MD5 md5 = new MD5CryptoServiceProvider();
|
||
|
byte[] data = System.Text.Encoding.Default.GetBytes(str);
|
||
|
byte[] md5data = md5.ComputeHash(data);
|
||
|
md5.Clear();
|
||
|
|
||
|
StringBuilder builder = new StringBuilder();
|
||
|
for (int i = 0; i < md5data.Length - 1; i++)
|
||
|
{
|
||
|
builder.Append(md5data[i].ToString("X2"));
|
||
|
}
|
||
|
return builder.ToString();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|