title: How to manually hash a password using Asp.Net Core 2.2 / IdentityServer4 / SP.NET Core Identity
body: <p>I am migrating tens of thousands of users from an old website that didn't have a password in the database to this new web application, however, when I try to import the users using the async method, it ends up taking several days to the point where I just ended up cancelling it after a few days.</p>
  
  <p>Now I have resorted to just creating new users directly from _context.Users.Add and assigning their roles, which i can do without a problem..  However, I can't seem to figure out how to create a generic password (all the same password) as these users will just be given a password to view a livestream (doesn't need to be super secure), but I still need the security part for the admin accounts that handle other stuff through the client/admin side UI.  If a user signs in, I will have it automatically enter the default password for them.</p>
  
  <p>For some reason though, I cannot get the password hasher to work correctly, as when I sign in, it says that the password is wrong...</p>
  
  <p>This is what I'm using to generate the password and create the users...</p>
  
  <pre><code> var appUser = new ApplicationUser() {
    Id = GenerateId(),
     AccessFailedCount = 0,
     Email = user[1],
     PasswordHash = "",
     FullName = "Standard User",
     UserName = user[1],
     PhoneNumber = user[8],
     FirstName = user[2],
     LastName = user[3],
     JoinMailingList = user[4],
     Country = user[5],
     City = user[6],
     StateRegion = user[7]
   };
  
   _context.Users.Add(appUser);
  
   var options = new PasswordHasherOptions();
   options.CompatibilityMode = PasswordHasherCompatibilityMode.IdentityV2;
  
   var hasher = new PasswordHasher &lt; ApplicationUser &gt; ();
   appUser.PasswordHash = hasher.HashPassword(appUser, "Default8!");
  
   var role = _context.Roles.FirstOrDefault(r =&gt; r.Name == "user");
  
   if (role != null) {
    var userRole = new IdentityUserRole &lt; string &gt; ();
    userRole.RoleId = role.Id;
    userRole.UserId = appUser.Id;
    _context.UserRoles.Add(userRole);
   }
  }
  
  _context.SaveChanges();
  </code></pre>
  
  <p>Can anyone help me out with how I'm supposed to Hash a password to store into the database?</p>