Net4x.Configuration.Crypt 2.5.0.26287

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

Net4x.Configuration.Crypt

Adds encryption of configuration values to Net4x.Configuration.Library. After encryption, values are stored AES-encrypted. They are decrypted as you read them, so application code keeps using ArgumentGetter.Instance["Key"] unchanged.

Installation

dotnet add package Net4x.Configuration.Crypt

Target frameworks: net35, net40, net45, net461, netstandard2.0.

Encrypting and decrypting the configuration

using ConfigurationLibrary.Crypt;

// Encrypt every value of ArgumentGetter.Instance.BaseConfig and save it.
ConfigurationCipher.CreateInstance().EncryptConfiguration();

// Reads now return plain text.
var password = ArgumentGetter.Instance["Pwd"];

// Turn it back into plain text on disk.
ConfigurationCipher.CreateInstance().DecryptConfiguration();

How it works:

  • The active configuration is wrapped, so values are decrypted on read and encrypted on write.
  • The key Encrypted records the current state (true / false). Calling either method a second time does nothing.
  • The result is written with Save(), which writes the per-user copy described in Net4x.Configuration.Library, not the file shipped with the application.

An encrypted appSettings section looks like this:

<appSettings>
  <add key="User"      value="Nd+mtOnETi7InTNPi0/H/g==" />
  <add key="Encrypted" value="gBiKnFXC+d9/ZfOSD50w7g==" />
</appSettings>

Encrypting single strings

var cipher = new StringCipher();
string encrypted = cipher.Encrypt("secret", "my-key");
string plain     = cipher.Decrypt(encrypted, "my-key");   // null if the key or data is wrong

The AES key and IV are derived from the key string with SHA-256. Decrypt returns null instead of throwing when the data is not valid ciphertext for that key.

Security note

EncryptConfiguration uses the file name of the Net4x.Configuration.Crypt assembly as its key. Anyone with the package can decrypt the values. Treat this as a way to keep values from being read at a glance, not as protection of secrets. For real secrets, use DPAPI, a key vault, or StringCipher with a key you manage yourself.

  • Net4x.Configuration.Library: the configuration being encrypted
  • Net4x.Configuration.Interfaces: shared contracts

Copyright (c) Piero Viano. All rights reserved. Authors: Piero Viano

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net35 is compatible.  net40 is compatible.  net403 was computed.  net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
2.5.0.26287 110 10/15/2026
2.5.0.26236 132 8/24/2026
2.5.0.5 169 7/17/2026
2.5.0.4 215 2/2/2026
2.5.0.3 229 1/23/2026
2.5.0.2 215 1/5/2026
2.5.0.1 230 12/30/2025
2.5.0 322 11/9/2025
1.6.0 380 3/31/2025
1.3.0 290 8/26/2023
1.3.0-at20230505032402 273 5/7/2023