DarkStrata.CredentialCheck 1.2.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package DarkStrata.CredentialCheck --version 1.2.3
                    
NuGet\Install-Package DarkStrata.CredentialCheck -Version 1.2.3
                    
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="DarkStrata.CredentialCheck" Version="1.2.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DarkStrata.CredentialCheck" Version="1.2.3" />
                    
Directory.Packages.props
<PackageReference Include="DarkStrata.CredentialCheck" />
                    
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 DarkStrata.CredentialCheck --version 1.2.3
                    
#r "nuget: DarkStrata.CredentialCheck, 1.2.3"
                    
#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 DarkStrata.CredentialCheck@1.2.3
                    
#: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=DarkStrata.CredentialCheck&version=1.2.3
                    
Install as a Cake Addin
#tool nuget:?package=DarkStrata.CredentialCheck&version=1.2.3
                    
Install as a Cake Tool

DarkStrata Credential Check - C# SDK

Check if credentials have been exposed in data breaches using k-anonymity to protect the credentials being checked.

NuGet License

Features

  • Privacy-First: Uses k-anonymity so your credentials are never sent to our servers
  • Type-Safe: Full nullable reference types and modern C# patterns
  • Async/Await: Native async support with cancellation tokens
  • Batch Processing: Check multiple credentials efficiently with automatic prefix grouping
  • Smart Caching: Built-in caching aligned with server HMAC rotation
  • Retry Logic: Automatic retries with exponential backoff
  • Comprehensive Errors: Typed exceptions for all error scenarios

Prerequisites

  • .NET 8.0 or later
  • DarkStrata API key (obtain from your dashboard)

Installation

dotnet add package DarkStrata.CredentialCheck

Or via Package Manager:

Install-Package DarkStrata.CredentialCheck

Quick Start

using DarkStrata.CredentialCheck;

// Create client
using var client = new DarkStrataCredentialCheck(new ClientOptions
{
    ApiKey = Environment.GetEnvironmentVariable("DARKSTRATA_API_KEY")!
});

// Check a credential
var result = await client.CheckAsync("user@example.com", "password123");

if (result.Found)
{
    Console.WriteLine("This credential was found in a data breach!");
}

How It Works

┌─────────────────┐         ┌─────────────────┐         ┌─────────────────┐
│                 │         │                 │         │                 │
│   Your App      │         │   DarkStrata    │         │   Breach DB     │
│                 │         │      API        │         │                 │
└────────┬────────┘         └────────┬────────┘         └────────┬────────┘
         │                           │                           │
    1. Hash credential               │                           │
    (SHA-256)                        │                           │
         │                           │                           │
    2. Send only first 5            │                           │
    chars of hash (prefix)───────────►                           │
         │                           │                           │
         │                      3. Find all matching             │
         │                      hashes with prefix ──────────────►
         │                           │                           │
         │                           │◄──────────────────────────┤
         │                      4. Apply HMAC to                 │
         │                      matching hashes                  │
         │                           │                           │
         │◄──────────────────────────┤                           │
    5. Compare HMAC                  │                           │
    locally                          │                           │
         │                           │                           │

Your actual credentials never leave your system - only a 5-character prefix of the hash is sent to the API.

API Reference

DarkStrataCredentialCheck

Constructor
new DarkStrataCredentialCheck(ClientOptions options)

ClientOptions: | Property | Type | Default | Description | |----------|------|---------|-------------| | ApiKey | string | required | Your DarkStrata API key | | BaseUrl | string? | https://api.darkstrata.io/v1/ | API base URL | | Timeout | TimeSpan? | 30 seconds | Request timeout | | Retries | int? | 3 | Number of retry attempts | | EnableCaching | bool? | true | Enable response caching | | CacheTtl | TimeSpan? | 1 hour | Cache time-to-live |

Methods
CheckAsync
Task<CheckResult> CheckAsync(
    string email,
    string password,
    CheckOptions? options = null,
    CancellationToken cancellationToken = default)

Check if a credential has been exposed in a data breach.

CheckHashAsync
Task<CheckResult> CheckHashAsync(
    string hash,
    CheckOptions? options = null,
    CancellationToken cancellationToken = default)

Check a pre-computed SHA-256 hash of email:password.

CheckBatchAsync
Task<IReadOnlyList<CheckResult>> CheckBatchAsync(
    IEnumerable<Credential> credentials,
    CheckOptions? options = null,
    CancellationToken cancellationToken = default)

Check multiple credentials efficiently with automatic prefix grouping.

CheckOptions

Property Type Description
ClientHmac string? Client-provided HMAC key for deterministic results (64+ hex chars)
Since DateTimeOffset? Filter breaches from this date onwards
SinceEpochDay int? Filter breaches from this epoch day onwards

CheckResult

Property Type Description
Found bool Whether the credential was found in a breach
Email string The email that was checked
Masked bool Always true - password is never returned
Metadata CheckMetadata Additional information about the check

Examples

Basic Check

var result = await client.CheckAsync("user@example.com", "password123");
Console.WriteLine($"Found: {result.Found}");
Console.WriteLine($"Prefix: {result.Metadata.Prefix}");
Console.WriteLine($"Total matches: {result.Metadata.TotalResults}");

Batch Check

var credentials = new Credential[]
{
    new("user1@example.com", "pass1"),
    new("user2@example.com", "pass2"),
    new("user3@example.com", "pass3"),
};

var results = await client.CheckBatchAsync(credentials);

foreach (var result in results)
{
    if (result.Found)
    {
        Console.WriteLine($"Compromised: {result.Email}");
    }
}

With Date Filter

// Only check breaches from 2024 onwards
var result = await client.CheckAsync("user@example.com", "password", new CheckOptions
{
    Since = new DateTimeOffset(2024, 1, 1, 0, 0, 0, TimeSpan.Zero)
});

Error Handling

try
{
    var result = await client.CheckAsync(email, password);
}
catch (AuthenticationException)
{
    Console.WriteLine("Invalid API key");
}
catch (RateLimitException ex)
{
    Console.WriteLine($"Rate limited. Retry after {ex.RetryAfter} seconds");
}
catch (DarkStrataTimeoutException ex)
{
    Console.WriteLine($"Request timed out after {ex.TimeoutMs}ms");
}
catch (NetworkException ex)
{
    Console.WriteLine($"Network error: {ex.Message}");
}
catch (ApiException ex)
{
    Console.WriteLine($"API error {ex.StatusCode}: {ex.ResponseBody}");
}

Exception Types

Exception Code Retryable Description
AuthenticationException 401 No Invalid API key
ValidationException - No Invalid input parameters
RateLimitException 429 Yes Rate limit exceeded
DarkStrataTimeoutException - Yes Request timed out
NetworkException - Yes Network connectivity issue
ApiException varies varies General API error

License

Apache 2.0 - see 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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.2 87 1/11/2026
2.0.1 83 1/11/2026
2.0.0 85 1/11/2026
1.3.0 94 1/8/2026
1.2.3 86 1/5/2026
1.2.2 169 12/23/2025
1.2.1 148 12/21/2025
1.2.0 151 12/21/2025
1.1.1 124 12/20/2025
1.1.0 114 12/20/2025