first commit

This commit is contained in:
yanpeng200212
2026-10-08 10:43:59 +08:00
commit 8430ba0452
288 changed files with 29595 additions and 0 deletions
@@ -0,0 +1,27 @@
using System.Security.Cryptography;
using System.Text;
using F9WebAiTest.Application.Interfaces.Security;
namespace F9WebAiTest.Infrastructure.InterfaceImplements.Security;
/// <summary>密码哈希服务实现(BCrypt)</summary>
public class PasswordHasher : IPasswordHasher
{
public string Hash256(string input)
{
var bytes = SHA256.HashData(Encoding.UTF8.GetBytes(input ?? ""));
return Convert.ToHexString(bytes).ToLowerInvariant();
}
public string GetMd5Hash(string input)
{
var bytes = MD5.HashData(Encoding.UTF8.GetBytes(input ?? ""));
return Convert.ToHexString(bytes).ToLowerInvariant();
}
public string HashPassword(string password)
=> BCrypt.Net.BCrypt.HashPassword(password);
public bool VerifyPassword(string password, string hashedPassword)
=> BCrypt.Net.BCrypt.Verify(password, hashedPassword);
}