42 lines
1.6 KiB
C#
42 lines
1.6 KiB
C#
// Copyright (c) .NET Foundation. All rights reserved.
|
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|
|
|
using System.Security.Cryptography;
|
|
|
|
namespace Microsoft.AspNetCore.Identity
|
|
{
|
|
/// <summary>
|
|
/// Specifies options for password hashing.
|
|
/// </summary>
|
|
public class PasswordHasherOptions
|
|
{
|
|
private static readonly RandomNumberGenerator _defaultRng = RandomNumberGenerator.Create(); // secure PRNG
|
|
|
|
/// <summary>
|
|
/// Gets or sets the compatibility mode used when hashing passwords.
|
|
/// </summary>
|
|
/// <value>
|
|
/// The compatibility mode used when hashing passwords.
|
|
/// </value>
|
|
/// <remarks>
|
|
/// The default compatibility mode is 'ASP.NET Identity version 3'.
|
|
/// </remarks>
|
|
public PasswordHasherCompatibilityMode CompatibilityMode { get; set; } = PasswordHasherCompatibilityMode.IdentityV3;
|
|
|
|
/// <summary>
|
|
/// Gets or sets the number of iterations used when hashing passwords using PBKDF2.
|
|
/// </summary>
|
|
/// <value>
|
|
/// The number of iterations used when hashing passwords using PBKDF2.
|
|
/// </value>
|
|
/// <remarks>
|
|
/// This value is only used when the compatibility mode is set to 'V3'.
|
|
/// The value must be a positive integer. The default value is 10,000.
|
|
/// </remarks>
|
|
public int IterationCount { get; set; } = 10000;
|
|
|
|
// for unit testing
|
|
internal RandomNumberGenerator Rng { get; set; } = _defaultRng;
|
|
}
|
|
}
|