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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Llc.GoodConsulting.Util.Extensions" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Llc.GoodConsulting.Util.Extensions" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Llc.GoodConsulting.Util.Extensions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Llc.GoodConsulting.Util.Extensions --version 1.0.2
                    
#r "nuget: Llc.GoodConsulting.Util.Extensions, 1.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Llc.GoodConsulting.Util.Extensions@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Llc.GoodConsulting.Util.Extensions&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Llc.GoodConsulting.Util.Extensions&version=1.0.2
                    
Install as a Cake Tool

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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.

Version Downloads Last Updated
1.0.2 138 12/20/2025
1.0.1 275 12/18/2025
1.0.0 273 12/17/2025