From the course: ASP.NET: Security

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Adding password hashing to the app

Adding password hashing to the app

From the course: ASP.NET: Security

Start my 1-month free trial

Adding password hashing to the app

- [Instructor] I have implemented a rather simple helper class which provides static methods to hash a password and to verify a password against a hash. So, I'm essentially storing the Hash and the Salt. Now, you could argue that you maybe should also store the number of iterations. This would be an idea for an additional refactoring of the app. So far, the number of iterations is constant and is always 10,000. Now, I'm using these two methods when I initialize the database. So, instead of just writing the passwords directly into the database, I'm hashing them. Of course, I could use the hashes here as well so I could precalculate them, but that way you just see how we can call the HashPassword functionality from here. In the User model, conveniently I already have the Salt and the Hash as properties, but I could and should get rid of the password. This change to the model will also lead to the situation that the database will be regenerated thanks to the Shopinitializer using…

Contents