OnProfNext/OnProfNext.Server/Services/PasswordHasher.cs
2025-10-14 12:57:40 +02:00

24 lines
708 B
C#

using Microsoft.AspNetCore.Cryptography.KeyDerivation;
using System.Security.Cryptography;
namespace OnProfNext.Server.Services
{
public static class PasswordHasher
{
public static string HashPassword(string password)
{
return BCrypt.Net.BCrypt.HashPassword(password, workFactor: 12);
}
public static bool VerifyPassword(string password, string hashedPassword)
{
if(string.IsNullOrWhiteSpace(password) || string.IsNullOrWhiteSpace(hashedPassword))
{
return false;
}
return BCrypt.Net.BCrypt.Verify(password, hashedPassword);
}
}
}