mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-04-30 20:58:01 +08:00
add md5
This commit is contained in:
parent
7bf9aa6c34
commit
8a48855f04
@ -97,6 +97,7 @@
|
||||
<Compile Include="JsonConverter.cs" />
|
||||
<Compile Include="JsonHelper.cs" />
|
||||
<Compile Include="LogHelper.cs" />
|
||||
<Compile Include="Md5.cs" />
|
||||
<Compile Include="ObjectHelper.cs" />
|
||||
<Compile Include="PredicateBuilder.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
31
Infrastructure/Md5.cs
Normal file
31
Infrastructure/Md5.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace Infrastructure
|
||||
{
|
||||
public class Md5
|
||||
{
|
||||
public static string Encrypt(string str)
|
||||
{
|
||||
|
||||
string pwd = String.Empty;
|
||||
|
||||
MD5 md5 = MD5.Create();
|
||||
|
||||
// 编码UTF8/Unicode
|
||||
byte[] s = md5.ComputeHash(Encoding.UTF8.GetBytes(str));
|
||||
|
||||
// 转换成字符串
|
||||
for (int i = 0; i < s.Length; i++)
|
||||
{
|
||||
//格式后的字符是小写的字母
|
||||
//如果使用大写(X)则格式后的字符是大写字符
|
||||
pwd = pwd + s[i].ToString("X");
|
||||
|
||||
}
|
||||
|
||||
return pwd;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user