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