mirror of
https://github.com/DrizzleTime/Foxel.git
synced 2026-05-13 07:01:03 +08:00
19 lines
541 B
C#
19 lines
541 B
C#
using System.Text;
|
|
namespace Foxel.Utils;
|
|
using System.Security.Cryptography;
|
|
|
|
public static class AuthHelper
|
|
{
|
|
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 storedHash)
|
|
{
|
|
var hashedPassword = HashPassword(password);
|
|
return hashedPassword == storedHash;
|
|
}
|
|
} |