using Microsoft.AspNetCore.Cryptography.KeyDerivation; using Microsoft.AspNetCore.Identity; using System.Collections.Generic; using System.Security.Cryptography; namespace Blazor.Models { public class Administrator : PasswordHasher { public int Id { get; private set; } public string Username { get; private set; } public string HashedPassword { get; set; } private byte[] salt = RandomNumberGenerator.GetBytes(128 / 8); // for password hash Administrator(int id, string username, string password) { this.Id = id; this.Username = username; // got this hashed password this.HashedPassword = Convert.ToBase64String(KeyDerivation.Pbkdf2( password: password!, salt: salt, prf: KeyDerivationPrf.HMACSHA256, iterationCount: 100000, numBytesRequested: 256 / 8) ); } } }