Naravel.Encryption 0.2.0

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

Naravel.Encryption

NuGet Downloads .NET 10 License: MIT

A thin Encrypt/Decrypt facade over ASP.NET Core Data Protection. No custom cryptography: keys, rotation and persistence stay in Data Protection.

Fact Detail
Install dotnet add package Naravel.Encryption
Targets .NET 10
Needs ASP.NET Core Data Protection (Microsoft.AspNetCore.DataProtection) and no other Naravel package

What you get

  • Strings and typed values. Encrypt returns URL-safe text, and Encrypt<T> carries any JSON-serializable value.
  • No custom cryptography. Every key and every byte of protection belongs to ASP.NET Core Data Protection.
  • Purposes. ForPurpose("name") keeps the payloads of different uses apart.
  • Safe on bad input. TryDecrypt returns false where Decrypt would throw DecryptException.
  • The key ring stays yours. Persist it where every instance can read it; the notes under the example say why.

Quick start

using Naravel.Encryption;

builder.Services.AddNaravelEncryption();   // adds ASP.NET Core Data Protection only if the application has not registered it

app.MapGet("/demo", (IEncrypter encrypter) =>
{
    var payload = encrypter.Encrypt("reset:42");
    return encrypter.TryDecrypt(payload, out var value) ? value : "unreadable";   // "reset:42"
});

Decrypt throws DecryptException for a payload that was changed, was encrypted for another purpose or whose key is no longer in the key ring; TryDecrypt returns false in those cases instead. Encrypt<T> and Decrypt<T> use reflection, so a trimmed or Native AOT application passes a JsonTypeInfo<T>.

A payload can be read only by an application that uses the same key ring and the same Data Protection application name. With more than one instance, or when old payloads must survive a restart, persist the key ring in a place every instance can read. That is ASP.NET Core Data Protection configuration, not part of this package.

Package Adds
Naravel.Queue.Encryption Optional: stores the payload of selected queue jobs encrypted

Learn more

Part of Naravel: Laravel's names, .NET's type system. All Naravel packages share one version.

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 (1)

Showing the top 1 NuGet packages that depend on Naravel.Encryption:

Package Downloads
Naravel.Queue.Encryption

Optional Naravel.Queue adapter that encrypts the payload of jobs marked IShouldBeEncrypted with ASP.NET Core Data Protection. Unmarked jobs keep the existing wire format.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.2.0 105 11/13/2026
0.1.1 116 11/2/2026
0.1.0 119 11/1/2026