Hashing In ASP.NET Core 2.0


How to use hash data (e.g. passwords) in ASP.NET Core.


The new Data Protection API in .NET Core includes functionality to create hashes using PBKDF2algorithm. ASP.NET Core uses this behind the scenes functionality in PasswordHasher class, which is used in ASP.NET Core Identity.

Create a class library and add the following NuGet package - 


Add a class to encapsulate the hashing logic.

Add a class to encapsulate the logic for creating a random salt.

Add tests to verify the functionality, e.g,

Source Code