NCode.Buffers
5.0.1
Prefix Reserved
dotnet add package NCode.Buffers --version 5.0.1
NuGet\Install-Package NCode.Buffers -Version 5.0.1
<PackageReference Include="NCode.Buffers" Version="5.0.1" />
<PackageVersion Include="NCode.Buffers" Version="5.0.1" />
<PackageReference Include="NCode.Buffers" />
paket add NCode.Buffers --version 5.0.1
#r "nuget: NCode.Buffers, 5.0.1"
#:package NCode.Buffers@5.0.1
#addin nuget:?package=NCode.Buffers&version=5.0.1
#tool nuget:?package=NCode.Buffers&version=5.0.1
NCode.Buffers
Pinned, pooled .NET buffers that zero themselves on dispose, for keys and other secrets, plus fixed-size buffer writers and string splitting without substring copies.
Installation
dotnet add package NCode.Buffers
The target frameworks are the ones the package's .csproj declares; they are listed on nuget.org's Frameworks tab and shown by the badge above. CHANGELOG.md records when a framework is added or dropped and which release line to stay on. The package depends on Nerdbank.Streams, whose Sequence<T> the pooled buffer writers return.
Example
This example derives a key from a password, verifies an HMAC-SHA256 signature with it, and zeroes the derived key and the expected MAC when the method returns.
using System.Security.Cryptography;
using NCode.Buffers;
public static class Signatures
{
public static bool VerifySignature(
ReadOnlySpan<byte> password,
ReadOnlySpan<byte> salt,
ReadOnlySpan<byte> payload,
ReadOnlySpan<byte> signature
)
{
// A pinned, pooled 32-byte key, zeroed when keyOwner is disposed.
using var keyOwner = BufferFactory.Rent(32, isSensitive: true, out Span<byte> key);
Rfc2898DeriveBytes.Pbkdf2(
password,
salt,
key,
iterations: 600_000,
HashAlgorithmName.SHA256
);
// The expected MAC lives on the stack and is zeroed when expectedLifetime is disposed.
Span<byte> expected = stackalloc byte[HMACSHA256.HashSizeInBytes];
using var expectedLifetime = expected.GetSecureLifetime();
HMACSHA256.HashData(key, payload, expected);
// Constant time, so the comparison doesn't reveal where the MACs differ.
return CryptographicOperations.FixedTimeEquals(expected, signature);
}
}
Learn more
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- JetBrains.Annotations (>= 2026.2.0)
- Nerdbank.Streams (>= 2.14.411)
NuGet packages (57)
Showing the top 5 NuGet packages that depend on NCode.Buffers:
| Package | Downloads |
|---|---|
|
NCode.Extensions.DataProtection
Extensions and utilities for ASP.NET Core Data Protection, including a type-safe factory pattern for creating IDataProtector instances with automatic purpose string derivation, and high-performance span-based protection operations using IBufferWriter. |
|
|
NCode.Identity.Secrets.AwsKms
AWS KMS key wrapper and remote key provider for NCode.Identity. |
|
|
NCode.Identity.Secrets.AzureKeyVault
Azure Key Vault key wrapper and remote key provider for NCode.Identity. |
|
|
NCode.Identity.Jose.EdDsa
Clean-room OKP (RFC 8037) support for NCode.Identity.Jose — an OKP secret-key type, EdDSA (Ed25519 / Ed448, RFC 8032) JWS signatures, and ECDH-ES key agreement over X25519 / X448 (RFC 7748), with no third-party cryptographic dependency. |
|
|
NCode.Identity.Cose.Abstractions
Contracts of CBOR Object Signing and Encryption (COSE, RFC 9052 / 9053) for NCode.Identity: the labels and values of COSE maps, the algorithm, key type and curve vocabularies as registered data, the COSE_Key converter and the COSE serializer. |
GitHub repositories
This package is not used by any popular GitHub repositories.
See the changelog: https://github.com/NCodeGroup/Buffers/blob/HEAD/CHANGELOG.md