Skip to content

NTDLS.Helpers Usage

Small static helpers for .NET 8 and 9, including PBKDF2 password hashing and human-readable file size formatting.

Published Jul 25, 2026

NTDLS.Helpers

What it is. A grab-bag of small static helper classes for .NET 8 and 9. The README is intentionally thin, so here is what the source actually ships: PasswordHashing (PBKDF2-SHA256 with a random salt), Formatters (human-readable file sizes), plus utilities for text, HTML, converters, null handling, threading and tasks.

When to reach for it. You want one-line implementations of common chores - password hashing, size formatting - without pulling in a large utility framework or writing the crypto plumbing yourself. Skip it if you need a documented, API-stable surface; this is a lightweight toolbox where each class does one job.

Getting started

The most useful piece is PasswordHashing, which hashes with PBKDF2-SHA256 (16-byte random salt, 210,000 iterations) and returns a single self-describing string:

using NTDLS.Helpers;

// When the user registers:
string storedHash = PasswordHashing.Hash("S3cret!Passw0rd");
// Stored format: {iterations}.{base64 salt}.{base64 hash}

// When the user logs in:
bool isValid = PasswordHashing.Verify("S3cret!Passw0rd", storedHash);

Because the iteration count and salt are embedded in the returned string, verification needs nothing but the stored value - no separate columns, and you can raise the iteration count later without rehashing everything.

For display work, Formatters.FileSize turns a raw byte count into a readable string:

Console.WriteLine(Formatters.FileSize(1_536_000m)); // e.g. "1.5 MB"

NuGet: NTDLS.Helpers

An unhandled error has occurred. Reload 🗙