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
<PackageReference Include="Net4x.Configuration.Crypt" Version="2.5.0.26287" />
<PackageVersion Include="Net4x.Configuration.Crypt" Version="2.5.0.26287" />
<PackageReference Include="Net4x.Configuration.Crypt" />
paket add Net4x.Configuration.Crypt --version 2.5.0.26287
#r "nuget: Net4x.Configuration.Crypt, 2.5.0.26287"
#:package Net4x.Configuration.Crypt@2.5.0.26287
#addin nuget:?package=Net4x.Configuration.Crypt&version=2.5.0.26287
#tool nuget:?package=Net4x.Configuration.Crypt&version=2.5.0.26287
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
Encryptedrecords 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 inNet4x.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.
Related packages
Net4x.Configuration.Library: the configuration being encryptedNet4x.Configuration.Interfaces: shared contracts
Copyright (c) Piero Viano. All rights reserved. Authors: Piero Viano
| Product | Versions 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. |
-
.NETFramework 3.5
- Net4x.Configuration.Interfaces (>= 2.5.0.26287)
- Net4x.Configuration.Library (>= 2.5.0.26287)
- Net4x.CoreLibrary.Base (>= 2.5.0.26286)
- Net4x.CoreLibrary.Threads (>= 2.5.0.26286)
-
.NETFramework 4.0
- Net4x.Configuration.Interfaces (>= 2.5.0.26287)
- Net4x.Configuration.Library (>= 2.5.0.26287)
- Net4x.CoreLibrary.Base (>= 2.5.0.26286)
- Net4x.CoreLibrary.Threads (>= 2.5.0.26286)
-
.NETFramework 4.5
- Net4x.Configuration.Interfaces (>= 2.5.0.26287)
- Net4x.Configuration.Library (>= 2.5.0.26287)
- Net4x.CoreLibrary.Base (>= 2.5.0.26286)
- Net4x.CoreLibrary.Threads (>= 2.5.0.26286)
-
.NETFramework 4.6.1
- Net4x.Configuration.Interfaces (>= 2.5.0.26287)
- Net4x.Configuration.Library (>= 2.5.0.26287)
- Net4x.CoreLibrary.Base (>= 2.5.0.26286)
- Net4x.CoreLibrary.Threads (>= 2.5.0.26286)
-
.NETStandard 2.0
- Net4x.Configuration.Interfaces (>= 2.5.0.26287)
- Net4x.Configuration.Library (>= 2.5.0.26287)
- Net4x.CoreLibrary.Base (>= 2.5.0.26286)
- Net4x.CoreLibrary.Threads (>= 2.5.0.26286)
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 |