Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在ASP.NET 5 Identity中设置PasswordHasher CompatibilityMode.IdentityV3?_C#_Asp.net Core_Asp.net Identity 3 - Fatal编程技术网

C# 如何在ASP.NET 5 Identity中设置PasswordHasher CompatibilityMode.IdentityV3?

C# 如何在ASP.NET 5 Identity中设置PasswordHasher CompatibilityMode.IdentityV3?,c#,asp.net-core,asp.net-identity-3,C#,Asp.net Core,Asp.net Identity 3,目前,默认值似乎设置为passwordhasher compatibilitymode.IdentityV2,这是ASP.NET 5中的HMAC-SHA1。我试图创建一个PasswordHasherOptions的实例来添加到服务(DI)中,但无法使其工作 V3使用PBKDF2和HMAC-SHA256、128位salt、256位子密钥、10000次迭代 我希望这将像将来的一些配置设置一样简单,而不必实现自定义实现,因为所有代码都已经存在 更新: services.Configure(option

目前,默认值似乎设置为
passwordhasher compatibilitymode.IdentityV2
,这是ASP.NET 5中的HMAC-SHA1。我试图创建一个
PasswordHasherOptions
的实例来添加到服务(DI)中,但无法使其工作

V3使用PBKDF2和HMAC-SHA256、128位salt、256位子密钥、10000次迭代

我希望这将像将来的一些配置设置一样简单,而不必实现自定义实现,因为所有代码都已经存在

更新:


services.Configure(options=>options.CompatibilityMode=passwordhasher-CompatibilityMode.IdentityV3)

默认值不应该是V2,默认值是更新的格式,如中所示

//
///默认兼容模式为“ASP.NET标识版本3”。
/// 
公共PasswordHashrCompatibilityMode CompatibilityMode{get;set;}=
PasswordHasher CompatibilityMode.IdentityV3;
如果哈希密码的第一个字节是0x01,则它是版本3哈希


如果您看到0x00,则可能是在代码中的其他位置配置的,或者是存在错误,在这种情况下,请将其登录到GitHub。

您是如何尝试注册
密码哈希选项的。介意发布您的
Configure
ConfigureServices
方法吗?谢谢,似乎就是这样。我会检查并返回。抱歉,我还不知道如何确认它是否是V3,我尝试在
Startup.ConfigureServices
中将模式设置为
passwordhashercompatitymode.IdentityV2
,但它仍在生成相同长度的散列,有什么建议吗?除非你能告诉我你用的是哪个版本的身份,否则我在这里做不了多少。每个存储密码的第一个字节是多少?附加问题-您希望的大小是多少?v3的格式是:{0x01,prf(UInt32),iter计数(UInt32),salt长度(UInt32),salt,subkey}。每个UInt32是4个字节。那么存储密码中的实际盐长度是多少?
    /// <remarks>
    /// The default compatibility mode is 'ASP.NET Identity version 3'.
    /// </remarks>
    public PasswordHasherCompatibilityMode CompatibilityMode { get; set; } = 
           PasswordHasherCompatibilityMode.IdentityV3;