Formats code comments as sentences in the production sources.

Capitalizes the first word and adds the terminal period across the domain, application, data access, infrastructure, API and web layers and the plugins. No comment is reworded. The change also normalizes the TODO bodies to lowercase, leaves commented-out code untouched, corrects the Threat/Treat typo and the dangling hyphen in the exception middleware, and collapses two accidental repeated terminal periods.
This commit is contained in:
BinaryAlley committed 2026-11-16 18:16:17 +02:00
1 parent 88455fec9c
commit 727aa33318
142 files changed
+403 -403

No files matched your search

@@ -13,12 +13,12 @@ namespace Lumina.Infrastructure.Core.Security;
/// </summary>
public sealed class PasswordHashService : IPasswordHashService
{
// OWASP recommended parameters for Argon2id
private const int MEMORY_SIZE = 19456; // 19 MiB (19 * 1024 = 19456)
// OWASP recommended parameters for Argon2id.
private const int MEMORY_SIZE = 19456; // 19 MiB (19 * 1024 = 19456).
private const int ITERATIONS = 2;
private const int DEGREE_OF_PARALLELISM = 1;
private const int HASH_SIZE = 32; // 256 bits
private const int SALT_SIZE = 16; // 128 bits
private const int HASH_SIZE = 32; // 256 bits.
private const int SALT_SIZE = 16; // 128 bits.
/// <summary>
/// Creates a hash from a string.
@@ -29,7 +29,7 @@ public sealed class PasswordHashService : IPasswordHashService
{
byte[] salt = new byte[SALT_SIZE];
using (RandomNumberGenerator rng = RandomNumberGenerator.Create())
rng.GetBytes(salt); // generate a random salt
rng.GetBytes(salt); // Generate a random salt.
byte[] hashBytes;
using (Argon2id hasher = new(Encoding.UTF8.GetBytes(password)))
@@ -40,7 +40,7 @@ public sealed class PasswordHashService : IPasswordHashService
hasher.Iterations = ITERATIONS;
hashBytes = hasher.GetBytes(HASH_SIZE);
}
// concatenate salt and hash and return as a Base64 string
// Concatenate salt and hash and return as a Base64 string.
byte[] hashWithSaltBytes = new byte[SALT_SIZE + HASH_SIZE];
Buffer.BlockCopy(salt, 0, hashWithSaltBytes, 0, SALT_SIZE);
Buffer.BlockCopy(hashBytes, 0, hashWithSaltBytes, SALT_SIZE, HASH_SIZE);
@@ -55,9 +55,9 @@ public sealed class PasswordHashService : IPasswordHashService
/// <returns><see langword="true"/> if <paramref name="password"/> and the de-hashed versions of <paramref name="hashedPassword"/> are equal, <see langword="false"/> otherwise.</returns>
public bool CheckStringAgainstHash(string password, string hashedPassword)
{
// convert the Base64 string back into a byte array
// Convert the Base64 string back into a byte array.
byte[] hashWithSaltBytes = Convert.FromBase64String(hashedPassword);
// validate the length too
// Validate the length too.
if (hashWithSaltBytes.Length != SALT_SIZE + HASH_SIZE)
return false;
@@ -73,10 +73,10 @@ public sealed class PasswordHashService : IPasswordHashService
hasher.Iterations = ITERATIONS;
hashBytes = hasher.GetBytes(HASH_SIZE);
}
// get the stored hash from the stored hashed password
// Get the stored hash from the stored hashed password.
byte[] storedHashBytes = new byte[HASH_SIZE];
Buffer.BlockCopy(hashWithSaltBytes, SALT_SIZE, storedHashBytes, 0, HASH_SIZE);
// use constant-time comparison to prevent timing attacks
// Use constant-time comparison to prevent timing attacks.
return CryptographicOperations.FixedTimeEquals(hashBytes, storedHashBytes);
}
}