Llc.GoodConsulting.Util.Extensions
1.0.2
dotnet add package Llc.GoodConsulting.Util.Extensions --version 1.0.2
NuGet\Install-Package Llc.GoodConsulting.Util.Extensions -Version 1.0.2
<PackageReference Include="Llc.GoodConsulting.Util.Extensions" Version="1.0.2" />
<PackageVersion Include="Llc.GoodConsulting.Util.Extensions" Version="1.0.2" />
<PackageReference Include="Llc.GoodConsulting.Util.Extensions" />
paket add Llc.GoodConsulting.Util.Extensions --version 1.0.2
#r "nuget: Llc.GoodConsulting.Util.Extensions, 1.0.2"
#:package Llc.GoodConsulting.Util.Extensions@1.0.2
#addin nuget:?package=Llc.GoodConsulting.Util.Extensions&version=1.0.2
#tool nuget:?package=Llc.GoodConsulting.Util.Extensions&version=1.0.2
Llc.GoodConsulting.Util.Extensions
A lightweight, dependency-free collection of C# extension methods focused on correctness, security, and modern .NET best practices.
This package provides carefully designed helpers for string comparison, spans, and common low-level operations that are easy to get wrong when re-implemented ad-hoc.
โจ Features
- ๐ Constant-time string & span comparisons (timing-attack resistant)
- โก Zero-allocation
ReadOnlySpan<T>implementations - ๐ง Clear, auditable code with explicit intent
- ๐งฉ Extension-method based API โ drop-in usage
- ๐ซ No external dependencies
- ๐งช Designed for security-sensitive and performance-critical code paths
๐ฆ Installation
.NET CLI
dotnet add package Llc.GoodConsulting.Util.Extensions
NuGet Package Manager
Install-Package Llc.GoodConsulting.Util.Extensions
๐ Constant-Time String Comparison
Why this matters
Naive string comparisons (==, Equals) can leak information via timing attacks, where an attacker infers secrets one character at a time based on response duration.
This library provides constant-time comparison utilities suitable for:
- API keys
- Tokens
- Webhook secrets
- HMAC verification
- Authentication and authorization flows
Example: Safe string comparison
using Llc.GoodConsulting.Util.Extensions;
if (providedToken.ConstantTimeEqualsSafe(storedToken))
{
AllowAccess();
}
- Resistant to timing attacks
- Handles different lengths safely
- Null-safe
Preferred: Zero-allocation ReadOnlySpan<char>
using Llc.GoodConsulting.Util.Extensions;
if (providedToken.AsSpan().ConstantTimeEquals(storedToken.AsSpan()))
{
AllowAccess();
}
Benefits:
- No allocations
- Works with slices and substrings
- Ideal for high-performance paths
Header / substring example
using Llc.GoodConsulting.Util.Extensions;
ReadOnlySpan<char> token = authorizationHeader.AsSpan(7); // skip "Bearer "
if (token.ConstantTimeEquals(expectedToken.AsSpan()))
{
AllowRequest();
}
๐ง Design Philosophy
This library follows a few core principles:
- Correctness over cleverness
- Security is explicit, not accidental
- Span-first APIs
- Small, composable helpers
Every method exists because it solves a real problem encountered in production code.
๐ก๏ธ Security Notes
These utilities mitigate algorithm-level timing attacks and are suitable for application-level security.
For raw cryptographic buffers, prefer:
using System.Security.Cryptography;
CryptographicOperations.FixedTimeEquals(aBytes, bBytes);
๐ฏ Target Frameworks
- .NET (modern runtimes)
- Compatible with C# 8.0+
๐ License
MIT License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Llc.GoodConsulting.Util.Extensions:
| Package | Downloads |
|---|---|
|
Llc.GoodConsulting.Language.Esperanto
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.