File size: 698 Bytes
de8b914
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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;
}