PasswordHasher 的使用

 

一段簡單的密碼加密與驗證範例

using Microsoft.AspNetCore.Identity;

var hashPw = new PasswordHasher<string>().HashPassword("", "1234");
if (new PasswordHasher<string>().VerifyHashedPassword("", hashPw, "1234") != PasswordVerificationResult.Failed)
{
    Console.WriteLine("pass");
}