This commit is contained in:
CortexCore
2023-10-02 23:24:56 +08:00
parent 8ef5c7ec0a
commit 947e52e748
183 changed files with 107857 additions and 9378 deletions

View File

@@ -0,0 +1,20 @@
using System;
using System.Security.Cryptography;
namespace BITKit.Crypto
{
public class BITCrypto:ICryptography
{
public string Salt { get; set; } = "2196F3";
public string Hash(string password)
{
var data = System.Text.Encoding.UTF8.GetBytes(password + Salt);
return Convert.ToBase64String(data);
}
public bool Verify(string password, string hash)
{
return Hash(password) == hash;
}
}
}

View File

@@ -0,0 +1,26 @@
namespace BITKit.Crypto
{
/// <summary>
/// 加密接口
/// </summary>
public interface ICryptography
{
/// <summary>
/// 盐
/// </summary>
public string Salt { get; set; }
/// <summary>
/// 获取Hash
/// </summary>
/// <param name="password"></param>
/// <returns></returns>
public string Hash(string password);
/// <summary>
/// 验证密码是否有效
/// </summary>
/// <param name="password">明文密码</param>
/// <param name="hash"></param>
/// <returns></returns>
public bool Verify(string password, string hash);
}
}