Search code examples
asp.netsecurityidentityasp.net-identity

Asp.net Identity password hashing


The new ASP.net Identity project has brought some useful code and interfaces for website security. To implement a custom system using the interfaces (instead of using the standard Entity Framework implementation included in the MVC 5 template) an IPasswordHasher is required.

IPasswordHasher interface in ASP.net Identity

namespace Microsoft.AspNet.Identity
{
    public interface IPasswordHasher
    {
         string HashPassword(string password);
         PasswordVerificationResult VerifyHashedPassword(string hashedPassword, string providedPassword);
    }
}

Is it possible to use password salting for more secure encryption in ASP.net Identity and via this interface?


Solution

  • "Is it possible to use password salting for more secure encryption in ASP.net Identity and via this interface?"

    Yes, the interface is provided for the new implementation of PasswordHasher already present in Core framework.

    Also note that the default implementation is already using Salt+Bytes.

    After creating custom PasswordHasher (say MyPasswordHasher), you can assign it to UserManager instance like userManager.PasswordHasher=new MyPasswordHasher()

    See one example of such IPasswordHasher

    To implement a custom system using the interfaces (instead of using the standard Entity Framework implementation included in the MVC 5 template) an IPasswordHasher is required.

    For implementing alternate system from EF, - You shall implement all Core interfaces. - IPasswordHasher implementation is not required. PasswordHasher is already provided in Core framework as it's implementation.