scm-api / src /SCM.Infrastructure /Security /PasswordHasherService.cs
rafaeldavila's picture
Deploy SCM API (.NET 8) - Docker Space
de8b914 verified
Raw History Blame Contribute Delete
698 Bytes
using Microsoft.AspNetCore.Identity;
using SCM.Application.Authentication;
namespace SCM.Infrastructure.Security;
/// <summary>Usa o <see cref="PasswordHasher{TUser}"/> do ASP.NET Core (PBKDF2 com salt).</summary>
public sealed class PasswordHasherService : IPasswordHasherService
{
private static readonly object Placeholder = new();
private readonly PasswordHasher<object> _hasher = new();
public string Hash(string password) => _hasher.HashPassword(Placeholder, password);
public bool Verify(string passwordHash, string providedPassword)
=> _hasher.VerifyHashedPassword(Placeholder, passwordHash, providedPassword)
!= PasswordVerificationResult.Failed;
}