Woof.DataProtection 7.0.0

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
dotnet add package Woof.DataProtection --version 7.0.0
NuGet\Install-Package Woof.DataProtection -Version 7.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="Woof.DataProtection" Version="7.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Woof.DataProtection --version 7.0.0
#r "nuget: Woof.DataProtection, 7.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.
// Install Woof.DataProtection as a Cake Addin
#addin nuget:?package=Woof.DataProtection&version=7.0.0

// Install Woof.DataProtection as a Cake Tool
#tool nuget:?package=Woof.DataProtection&version=7.0.0


A part of the Woof Tookit by CodeDog.

Distributed under MIT License. (c)2022 by CodeDog, All rights reserved.


Provides a basic abstraction for the DataProtection API and data protection methods for Windows.

Although the most of the Woof Toolkit is multi-platform, the Windows DataProtection API is built in both in the framework and the operating system. For other operating systems additional coding and setup is required.

The goal of this module is to relay all the OS specific operations to the extending packages, like Woof.DataProtection.Linux.

If the OS specific extension package is present in the project, it will be used to provide the data protection API.


Binary data protection:

var encrypted = DP.Protect(sensitiveData);
var decrypted = DP.Unprotect(encrypted);

String data protection:

var encryptedText = DP.Protect(plainText);
var decryptedText = DP.Unprotect(encryptedText);

To test if the data protection is available on target system:

if (DP.IsAvailable) {  
    // use the data protection

An optional parameter of type DataProtectionScope can be used. If this parameter is not specified, the default protection scope is DataProtectionScope.CurrentUser.

Windows service usage

The package uses System.Security.Cryptography DPAPI by default. However, when the program is run by a Windows Service on LOCAL SYSTEM account, the system encryption key is not available to the service.

That would result in following exception being thrown:

Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException: The system cannot find the path specified.

In order to fix that in this case a special service API can be used.

To use Microsoft.AspNetCore.DataProtection API instead of System.Security.Cryptography set the data protection scope to LocalSystem instead of LocalMachine.


Woof Toolkit is a work in progress in constant development, however it's carefully maintained with production code quality.

PLEASE report all issues on GitHub!

Describe how to reproduce an issue. Also feel free to suggest new features or improvements.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Woof.DataProtection:

Package Downloads
Woof.Settings.Protected The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

Provides application settings in a JSON file, uses data protection to encrypt file contents.

Woof.DataProtection.Linux The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

Provides data protection API for Linux.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
7.0.0 192 8/6/2023
6.2.0 317 2/20/2022

.NET7 target.