Woof.DataProtection
7.0.0
Prefix Reserved
dotnet add package Woof.DataProtection --version 7.0.0
NuGet\Install-Package Woof.DataProtection -Version 7.0.0
<PackageReference Include="Woof.DataProtection" Version="7.0.0" />
paket add Woof.DataProtection --version 7.0.0
#r "nuget: Woof.DataProtection, 7.0.0"
// 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
Woof.DataProtection
A part of the Woof Tookit by CodeDog.
Distributed under MIT License. (c)2022 by CodeDog, All rights reserved.
About
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.
Usage
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
.
Disclaimer
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 | Versions 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. |
-
net7.0
- Microsoft.AspNetCore.DataProtection (>= 6.0.2)
- Microsoft.AspNetCore.DataProtection.Abstractions (>= 6.0.2)
- Microsoft.AspNetCore.DataProtection.Extensions (>= 6.0.2)
- System.Security.Cryptography.ProtectedData (>= 6.0.0)
- Woof.Internals (>= 7.0.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Woof.DataProtection:
Package | Downloads |
---|---|
Woof.Settings.Protected
Provides application settings in a JSON file, uses data protection to encrypt file contents. |
|
Woof.DataProtection.Linux
Provides data protection API for Linux. |
GitHub repositories
This package is not used by any popular GitHub repositories.
.NET7 target.