using Monitoring.Core.Domain.UserPrimitives;
using Monitoring.Infrastructure.Abstractions;

namespace Monitoring.Infrastructure.Services;

public class PasswordService : IPasswordService
{
	public PasswordHash Hash(Password password)
	{
		return PasswordHash.Create(
			BCrypt.Net.BCrypt.HashPassword(password.Value));
	}

	public bool Verify(Password password, PasswordHash hash)
	{
		return BCrypt.Net.BCrypt.Verify(password.Value, hash.Value);
	}

	public PasswordHash HashWithFixedSalt(Password password, PasswordSalt fixedSalt)
	{
		return PasswordHash.Create(
			BCrypt.Net.BCrypt.HashPassword(password.Value, fixedSalt.Value));
	}
}