添加项目文件。

This commit is contained in:
PastSaid
2023-12-08 23:53:07 +08:00
parent 8b00e15a57
commit c4fceda660
34 changed files with 3378 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
namespace SAL_OUTSTOCK.Utils
{
internal static class SHA256Helper
{
/// <summary>
/// SHA256加密
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public static string SHA256EncryptString(string data)
{
byte[] bytes = Encoding.UTF8.GetBytes(data);
byte[] hash = SHA256Managed.Create().ComputeHash(bytes);
StringBuilder builder = new StringBuilder();
for (int i = 0; i < hash.Length; i++)
{
builder.Append(hash[i].ToString("x2"));
}
return builder.ToString();
}
/// <summary>
/// SHA256加密
/// </summary>
/// <param name="StrIn">待加密字符串</param>
/// <returns>加密数组</returns>
public static Byte[] SHA256EncryptByte(string StrIn)
{
var sha256 = new SHA256Managed();
var Asc = new ASCIIEncoding();
var tmpByte = Asc.GetBytes(StrIn);
var EncryptBytes = sha256.ComputeHash(tmpByte);
sha256.Clear();
return EncryptBytes;
}
}
}