【发布时间】:2016-07-20 16:13:00
【问题描述】:
在我的一生中,我无法在没有任何更改的模板 ASP.NET MVC 应用程序中识别 Cryptography.KeyDerivation。我环顾四周,有些节目
使用 Microsoft.AspNetCore.Cryptography.KeyDerivation;
-或-
使用 Microsoft.AspNet.Cryptography.KeyDerivation;
-但甚至-
使用 System.Security.Cryptography.KeyDerivation;未列出@
https://msdn.microsoft.com/en-us/library/system.security.cryptography%28v=vs.110%29.aspx
我想使用我在网上找到的代码来覆盖使用 HMACSHA1 并改用 HMACSHA526 的 PasswordHasher 的默认版本:
string hashed = Convert.ToBase64String(KeyDerivation.Pbkdf2(
password: password,
salt: salt,
prf: KeyDerivationPrf.HMACSHA1,
iterationCount: 10000,
numBytesRequested: 256 / 8));
并使用 HMACSHA512 的 prf 来覆盖 PasswordHasher 的基类,该基类只有一个带有要传入的密码的构造函数。
最后一个问题,一旦完成而不是创建一个单独的覆盖类,我可以不只是将代码粘贴在 ApplicationUserManager 中吗?
public ApplicationUserManager(IUserStore<ApplicationUser> store) : base(store)
{
//code here
}
【问题讨论】:
标签: c# asp.net-mvc hashcode visual-studio-2015