WindowsCredentialManagerAPI 1.0.0

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

WindowsCredentialManagerAPI

A .NET library that provides managed access to the Windows Credential Manager for storing, retrieving, enumerating, and deleting credentials securely.
It wraps the native Win32 Credential APIs (advapi32.dll) and offers a clean C# API with support for SecureString.


✨ Features

  • Save credentials (username + password) to the Windows Credential Manager
  • Retrieve credentials as plain text (NetworkCredential) or as secure (SecureNetworkCredential)
  • Delete credentials
  • Enumerate all stored credentials with optional filter
  • Check if a credential exists
  • Supports multiple CredentialType and CredentialPersistence modes
  • Handles memory securely (clears sensitive buffers, supports SecureString)

πŸ“¦ Installation

dotnet add package WindowsCredentialManagerAPI
πŸš€ Quickstart
csharp
Code kopieren
using WindowsCredentialManagerAPI;

// Save a credential
WindowsCredentialManager.SaveCredential(
    target: "MyApp/Api",
    username: "testuser",
    password: "SuperSecretPassword123!"
);

// Retrieve a credential
var cred = WindowsCredentialManager.GetCredential("MyApp/Api");
if (cred != null)
{
    Console.WriteLine($"Username: {cred.Username}, Password: {cred.Password}");
}

// Delete a credential
WindowsCredentialManager.DeleteCredential("MyApp/Api");
With SecureString
csharp
Code kopieren
using System.Security;
using WindowsCredentialManagerAPI;

var securePwd = new SecureString();
foreach (char c in "SuperSecretPassword123!")
    securePwd.AppendChar(c);
securePwd.MakeReadOnly();

WindowsCredentialManager.SaveCredential(
    target: "MyApp/ApiSecure",
    username: "secureuser",
    securePassword: securePwd
);

var secureCred = WindowsCredentialManager.GetSecureCredential("MyApp/ApiSecure");
if (secureCred != null)
{
    Console.WriteLine($"Username: {secureCred.Username}, SecurePasswordLength: {secureCred.Password.Length}");
    secureCred.Dispose(); // cleans up SecureString
}
πŸ”§ API Overview
SaveCredential(target, username, password, type, persistence)

SaveCredential(target, username, SecureString securePassword, type, persistence)

GetCredential(target, type) β†’ NetworkCredential

GetSecureCredential(target, type) β†’ SecureNetworkCredential

DeleteCredential(target, type)

EnumerateCredentials(filter) β†’ List<CredentialInfo>

CredentialExists(target, type)

πŸ”’ Security Notes
All passwords stored in Credential Manager are protected by Windows’ Data Protection API (DPAPI).

This library ensures that sensitive byte arrays are cleared from memory after use.

Prefer using SecureString APIs when possible.
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
1.0.2 259 9/9/2025
1.0.1 199 9/9/2025
1.0.0 211 9/8/2025

Initial release with full Windows Credential Manager API support