I have two different applications that are both running on aspnetcore. In application A I want to generate a new password, hash it, and store it in the database of application B, so a user can use this password to log into application B.
private static string HashPassword(string password)
{
var hasher = new PasswordHasher<MockUser>(new OptionsWrapper<PasswordHasherOptions>(new PasswordHasherOptions{CompatibilityMode = PasswordHasherCompatibilityMode.IdentityV3}));
var user = new MockUser();
var hashedPw = hasher.HashPassword(user, password);
return hashedPw;
}
private class MockUser : IdentityUser
{
}
If I subsequently store this password in application B, I can however not log in with the set password in application B. Application B uses the aspnetcore UserManager to manage logins. UserManager also uses PasswordHasher.HashPassword to set a password on users, and the user object that is passed does not affect the resulting hash, so I would expect it to work, however it does not.
Can anyone point me in the correct direction as to why hashing the password in application A does not result in a hash that allows me to log in at application B? I already tried both V3 and V2 options for the passwordhasher.