add(接口):添加授权、用户、好友关系服务接口

This commit is contained in:
2025-10-28 16:52:59 +08:00
parent d85e906b39
commit c67c666135
20 changed files with 967 additions and 8 deletions
+22
View File
@@ -0,0 +1,22 @@
using System.Security.Cryptography;
using System.Text;
namespace IM_API.Tools
{
public static class PasswordHasher
{
public static string HashPassword(string password)
{
using var sha256 = SHA256.Create();
var hashedBytes = sha256.ComputeHash(Encoding.UTF8.GetBytes(password));
return Convert.ToBase64String(hashedBytes);
}
public static bool VerifyPassword(string password, string hashedPassword)
{
var hashedInput = HashPassword(password);
return hashedInput == hashedPassword;
}
}
}
}