Skip to content

Commit 912eb9f

Browse files
committed
XML docs
1 parent ba25eb1 commit 912eb9f

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/ScottBrady91.AspNetCore.Identity.BCryptPasswordHasher/BCryptPasswordHasher.cs

+23
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,45 @@
44

55
namespace ScottBrady91.AspNetCore.Identity
66
{
7+
/// <summary>
8+
/// ASP.NET Core Identity password hasher using the bcrypt password hashing algorithm.
9+
/// </summary>
10+
/// <typeparam name="TUser">your ASP.NET Core Identity user type (e.g. IdentityUser). User is not used by this implementation</typeparam>
711
public class BCryptPasswordHasher<TUser> : IPasswordHasher<TUser> where TUser : class
812
{
913
private readonly BCryptPasswordHasherOptions options;
1014

15+
/// <summary>
16+
/// Creates a new BCryptPasswordHasher.
17+
/// </summary>
18+
/// <param name="optionsAccessor">optional BCryptPasswordHasherOptions</param>
1119
public BCryptPasswordHasher(IOptions<BCryptPasswordHasherOptions> optionsAccessor = null)
1220
{
1321
options = optionsAccessor?.Value ?? new BCryptPasswordHasherOptions();
1422
}
1523

24+
/// <summary>
25+
/// Hashes a password using bcrypt.
26+
/// </summary>
27+
/// <param name="user">not used for this implementation</param>
28+
/// <param name="password">plaintext password</param>
29+
/// <returns>hashed password</returns>
30+
/// <exception cref="ArgumentNullException">missing plaintext password</exception>
1631
public virtual string HashPassword(TUser user, string password)
1732
{
1833
if (string.IsNullOrWhiteSpace(password)) throw new ArgumentNullException(nameof(password));
1934

2035
return BCrypt.Net.BCrypt.HashPassword(password, options.WorkFactor, options.EnhancedEntropy);
2136
}
2237

38+
/// <summary>
39+
/// Verifies a plaintext password against a stored hash.
40+
/// </summary>
41+
/// <param name="user">not used for this implementation</param>
42+
/// <param name="hashedPassword">the stored, hashed password</param>
43+
/// <param name="providedPassword">the plaintext password to verify against the stored hash</param>
44+
/// <returns>If the password matches the stored password. Returns SuccessRehashNeeded if the work factor has changed</returns>
45+
/// <exception cref="ArgumentNullException">missing plaintext password or hashed password</exception>
2346
public virtual PasswordVerificationResult VerifyHashedPassword(TUser user, string hashedPassword, string providedPassword)
2447
{
2548
if (string.IsNullOrWhiteSpace(hashedPassword)) throw new ArgumentNullException(nameof(hashedPassword));

src/ScottBrady91.AspNetCore.Identity.BCryptPasswordHasher/BCryptPasswordHasherOptions.cs

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
namespace ScottBrady91.AspNetCore.Identity
22
{
3+
/// <summary>
4+
/// Options for BCryptPasswordHasher.
5+
/// </summary>
36
public class BCryptPasswordHasherOptions
47
{
58
/// <summary>

0 commit comments

Comments
 (0)