fm.Extensions.DataProtection 7.0.0

dotnet add package fm.Extensions.DataProtection --version 7.0.0
                    
NuGet\Install-Package fm.Extensions.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="fm.Extensions.DataProtection" Version="7.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="fm.Extensions.DataProtection" Version="7.0.0" />
                    
Directory.Packages.props
<PackageReference Include="fm.Extensions.DataProtection" />
                    
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 fm.Extensions.DataProtection --version 7.0.0
                    
#r "nuget: fm.Extensions.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.
#:package fm.Extensions.DataProtection@7.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=fm.Extensions.DataProtection&version=7.0.0
                    
Install as a Cake Addin
#tool nuget:?package=fm.Extensions.DataProtection&version=7.0.0
                    
Install as a Cake Tool

About

Makes using the Microsoft.AspNet.DataProtection package more convenient, especially when using IAuthenticatedEncryptor.

Example

[TestClass]
public sealed class ExampleTests : ServiceTestsBase // Provided by fm.Extensions.Testing.DependencyInjection
{
    protected override void ConfigureServices(IServiceCollection services)
    {
        base.ConfigureServices(services);
        // Add the AuthenticatedEncryptorFactory for creating encryptors.
        services.AddSingleton<IAuthenticatedEncryptorFactory, AuthenticatedEncryptorFactory>();
    }

    [TestMethod]
    public void RandomTest()
    {
        // Create a secret
        SecretKey key = new SecretKey(
            new Secret("Password"u8.ToArray()),
            this.GetRequiredService<IAuthenticatedEncryptorFactory>());
        // Create an encryptor to encrypt and decrypt data
        IAuthenticatedEncryptor encryptor = key.CreateEncryptor().ShouldNotBeNull();

        byte[] ciphertext = encryptor.Encrypt("Input", "AAD").ShouldCount(80, "Should be 80 bytes.");

        encryptor.DecryptToString(ciphertext, "AAD").ShouldBe("Input");
    }
}

Main Types

The main types provided by this library are:

  • AuthenticatedEncryptorExtensions
  • EncryptorEncoding
  • SecretKey
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.

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
7.0.0 183 11/26/2025
6.0.0 250 11/15/2024
5.0.2 147 10/22/2024
5.0.1 199 5/15/2024
5.0.0 217 3/27/2024
4.0.0 443 3/4/2023
3.2.0 556 10/10/2022
3.1.0 1,358 11/11/2021
3.0.0 5,223 11/17/2020
2.3.0 6,787 1/4/2020
2.2.0 1,130 11/22/2019
2.0.0 2,069 10/9/2017
1.0.0 2,049 6/29/2016

- BREAKING: Target .NET 10
- BREAKING: Remove redundant extension APIs.
- BREAKING: Make use of implicit `ArraySegment` conversion.