I would define a user class as follows:
public class User
{
private string PasswordHash {get; set;}
public void SetPassword(string newPassword)
{
PasswordHash = PasswordHasher.CreateHash(newPassword);
}
public bool VerifyPassword(string passwordCandidate)
{
return PasswordHasher.Verify(PasswordHash, passwordCandidate);
}
}
I would not have a property User.Password, since you never store it, and there is no simple mapping between passwords and hashes.
PasswordHash . , / .
API Crypto. Crypto .