I have a project where we need to migrate a lot of users that has their password in plain text into a new database where we will hash the password.
The new system use Entity Framework and it needs to be authenticated with the Asp.Net Identity framework.
I found that I can generate in C# a correct hashed password that Entity Framework can read without problem.
public static string HashPassword(string password)
{
byte[] salt;
byte[] buffer2;
using (var bytes = new Rfc2898DeriveBytes(password, 0x10, 0x3e8))
{
salt = bytes.Salt;
buffer2 = bytes.GetBytes(0x20);
}
byte[] dst = new byte[0x31];
Buffer.BlockCopy(salt, 0, dst, 1, 0x10);
Buffer.BlockCopy(buffer2, 0, dst, 0x11, 0x20);
return Convert.ToBase64String(dst);
}
Is there something similar in SQL that I could use within INSERT statement form a SELECT to the other table?
TempPasswordcolumn inuserstable. Then a small console app that will go into every record and generate password hash from the plain text and update the record with the hash. Console app will probably be about 30 lines. Then validate you can login and then dropTempPasswordcolumn. Quick and dirty, good enough for one-time migration.