summaryrefslogtreecommitdiffstats
path: root/src/Utilities/PasswordHasher.cs
blob: 213e03d5a8894d6a313826ce4fc881a271cc2156 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
using IOL.Fagprove.Data.Models;
using Microsoft.AspNetCore.Identity;

namespace IOL.Fagprove.Utilities
{
    public static class PasswordHasher
    {
        public static string HashPassword(string password) {
            var hasher = new PasswordHasher<User>();
            return hasher.HashPassword(null, password);
        }

        public static bool PasswordMatches(string hash, string password) {
            var hasher = new PasswordHasher<User>();
            return hasher.VerifyHashedPassword(null, hash, password) == PasswordVerificationResult.Success;
        }
    }
}