mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-18 09:44:28 +08:00
修改部分文件结构,完善第三方登陆功能
This commit is contained in:
@@ -84,6 +84,7 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Response.cs" />
|
||||
<Compile Include="SessionHelper.cs" />
|
||||
<Compile Include="StringExtensions.cs" />
|
||||
<Compile Include="UriUtil.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
31
Infrastructure/StringExtensions.cs
Normal file
31
Infrastructure/StringExtensions.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace Infrastructure
|
||||
{
|
||||
public static class StringExtensions
|
||||
{
|
||||
public static string MaxSubstring(this string origin, int maxLength)
|
||||
{
|
||||
return origin.Length >= maxLength ? origin.Substring(0, maxLength) : origin;
|
||||
}
|
||||
|
||||
public static string ToMd5(this string origin)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(origin))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var md5Algorithm = MD5.Create();
|
||||
var utf8Bytes = Encoding.UTF8.GetBytes(origin);
|
||||
var md5Hash = md5Algorithm.ComputeHash(utf8Bytes);
|
||||
var hexString = new StringBuilder();
|
||||
foreach (var hexByte in md5Hash)
|
||||
{
|
||||
hexString.Append(hexByte.ToString("x2"));
|
||||
}
|
||||
return hexString.ToString();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user