EngineBay.DataProtection 2.0.3

dotnet add package EngineBay.DataProtection --version 2.0.3                
NuGet\Install-Package EngineBay.DataProtection -Version 2.0.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="EngineBay.DataProtection" Version="2.0.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EngineBay.DataProtection --version 2.0.3                
#r "nuget: EngineBay.DataProtection, 2.0.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.
// Install EngineBay.DataProtection as a Cake Addin
#addin nuget:?package=EngineBay.DataProtection&version=2.0.3

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

EngineBay.DataProtection

NuGet version Maintainability Test Coverage

DataProtection module for EngineBay published to EngineBay.DataProtection on NuGet.

About

Registering and configuring this module will add a DataProtectionProvider to your service collection, making it available for dependency injection. You can use this provider to encrypt and decrypt text, which is useful when storing sensitive data.

For any fields that you wish to be encrypted while stored in your database, the DataProtectionProvider should be used to encrypt before storing, and decrypt when you wish to access the value. This means that the data protection mechanism is agnostic to which database system you use.

Warning: Whilst this module provides the options to store your encryption keys in a local files system or on a redis server, it cannot back up your keystore. Ensure you have a secure backup strategy. If you lose the keys, you will lose access to the data.

Read more about data protection here.

Usage

If the module is registered, accessing it in any other module's class is as simple as normal dependency injection: specify IDataProtectionProvider dataProtectionProvider as a constructor parameter.

To use this, you will need to create a protector and use it to protect or unprotect your desired strings.

To encrypt:

var dataProtector = dataProtectionProvider.CreateProtector("Reason for encrypting");
var encryptedMessage = dataProtector.Protect(message);

To unencrypt:

var dataProtector = dataProtectionProvider.CreateProtector("Reason for encrypting");
var message = dataProtector.Unprotect(encryptedMessage);

For an example of a model with a field that is stored encrypted at rest, see the EncryptedMessage field for SessionLog from EngineBay.ActorEngine.

Registration

This module cannot run on its own. You will need to register it in your application to use its functionality. See the Demo API registration guide.

Environment Variables

See the Documentation Portal.

Dependencies

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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on EngineBay.DataProtection:

Package Downloads
EngineBay.ActorEngine

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.3 381 1/9/2024
2.0.2 261 12/20/2023
2.0.1 263 12/7/2023
2.0.0 198 11/23/2023
1.1.0 182 11/15/2023
1.0.3 301 10/31/2023
1.0.2 124 10/31/2023
1.0.0 547 9/28/2023
0.1.1 129 9/27/2023
0.1.0 182 9/27/2023