How to reproduce ASP.NET MVC 4 password hash, produced by the built-in membership system?
Example:
Input: loz123
Output: APeJ4h0M4h7OFz91WwmJUjFfI2Daiq5xaUaZzcevoyWfkPZ3SYFJ48F+YzNrBNvaJA==
The "Salt" field in database is empty.
I am transferring data from one database to another. In the source database passwords are stored as plain text. In the destination database, the passwords should be stored as hashes generated by ASP.NET Membership system. I know the hashing is something about using SHA1 algorithm and base64 encoding, but I can't get the correct outputs. It would be convenient if there was a built-in function in MS SQL Server, so that a query such as the following could be executed:
SELECT Username, Hash(Password) FROM Users
This may help you to get to the right algorithm:
http://msdn.microsoft.com/en-us/library/system.web.security.sqlmembershipprovider.passwordformat.aspx
You will have to check your specific settings.
The summary from MSDN:
I had to update an older database with "clear" passwords to "hashed" and I wanted to do it with sql - this is what I came up with to make the switch fast and easy.
NOTE: Make a backup first!!
Function to calculate the hashes:
Call it like this:
Even with my database originally set to "clear" passwords, the salt values were created with each record, however, if for some reason you don't have salt values you can create them with this:
Then use it like this:
Note that you need to generate the Salts FIRST, then the hashes. Enjoy!