Backend/e-suite.Nuget.PasswordHasher/e-suite.Nuget.PasswordHasher/CustomPasswordHasherOptions.cs
2026-01-20 21:50:10 +00:00

45 lines
1.6 KiB
C#

namespace e_suite.Nuget.PasswordHasher;
/// <summary>
/// Specifies options for password hashing.
/// </summary>
public class CustomPasswordHasherOptions
{
public CustomPasswordHasherOptions()
{
PepperDictionary = new Dictionary<int, byte[]>
{
{0, Array.Empty<byte>()}
};
}
/// <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 CustomPasswordHasherMethod CompatibilityMode { get; set; } = CustomPasswordHasherMethod.formulaThree;
/// <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;
/// <summary>
/// Add pepper byte arrays to apply to the password before hashing.
/// The pepper with the highest index will be used for hashing new passwords.
/// Older peppers added to the list allow verification against older hashed passwords.
/// Index 0 is reserved to indicate that no pepper is used.
/// </summary>
public Dictionary<int, byte[]> PepperDictionary { get; }
}