DBGang.Configuration.SecuredJson 1.1.2

This is a direct extension to Microsoft.Extensions.Configuration.Json. It adds features to protect sensitive data in the specified JSON configuration file.

1.1.0:
   - Changed the package namespace
   - Added support for custom passphrase used in encryption algorithm
1.1.1
   - Added a Readme.txt
1.1.2
   - Added MIT license

Install-Package DBGang.Configuration.SecuredJson -Version 1.1.2
dotnet add package DBGang.Configuration.SecuredJson --version 1.1.2
<PackageReference Include="DBGang.Configuration.SecuredJson" Version="1.1.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DBGang.Configuration.SecuredJson --version 1.1.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

This is an expansion to Microsoft.Extensions.Configuration.Json. It adds features to protect sensitive data in JSON configuration file.

Here is an example to show how to use the it in a console application:

using System;
using Microsoft.Extensions.Configuration;
using DBGang.Configuration.SecuredJson;

namespace TestSecuredJson
{
class Program
{
static void Main(string[] args)
{
IConfiguration config = new ConfigurationBuilder()
.SetBasePath(Environment.CurrentDirectory)
.AddSecuredJsonFile("sample.json")
// Optionally you can provide your own Passphrase to encrypt
// the configuration data.
//.AddSecuredJsonFile("sample.json", "myPassphrase")
.Build();

    Console.WriteLine(config.GetConnectionString("MyDB"));
    Console.WriteLine(config["key1"]);
    Console.WriteLine(config["key2"]);
}

}
}

When you create the JSON file initially, you add "unencrypted:" as prefix to values you want to protect, like this:
{
"ConnectionStrings": {
"MyDB": "unencrypted:Server=myServer;Database=myDatabase;User Id=myUsername;Password=myPassword;"
},
"key1": "value1",
"key2": "unencrypted:value2"
}

When your application runs, if it detects this, it encrypts the value and saves the encrypted value back to the JSON file so the file will look like:
{
"ConnectionStrings": {
"MyDB": "encrypted:npKy+h1OZb5LYt500EuotjPMflb+tg6TARUUJ3LYnb0E40W/YkOdc545PlMKd+dQl9lqZiYEQNvK3gk08tlKi2qJitXKXUTJdf0ANhgGtGM="
},
"key1": "value1",
"key2": "encrypted:sbv8Nz8MyyanNPRtlfCopw=="
}

The encrypted value will be decrypted automatically at the subsequent runs of your application.

This is an expansion to Microsoft.Extensions.Configuration.Json. It adds features to protect sensitive data in JSON configuration file.

Here is an example to show how to use the it in a console application:

using System;
using Microsoft.Extensions.Configuration;
using DBGang.Configuration.SecuredJson;

namespace TestSecuredJson
{
class Program
{
static void Main(string[] args)
{
IConfiguration config = new ConfigurationBuilder()
.SetBasePath(Environment.CurrentDirectory)
.AddSecuredJsonFile("sample.json")
// Optionally you can provide your own Passphrase to encrypt
// the configuration data.
//.AddSecuredJsonFile("sample.json", "myPassphrase")
.Build();

    Console.WriteLine(config.GetConnectionString("MyDB"));
    Console.WriteLine(config["key1"]);
    Console.WriteLine(config["key2"]);
}

}
}

When you create the JSON file initially, you add "unencrypted:" as prefix to values you want to protect, like this:
{
"ConnectionStrings": {
"MyDB": "unencrypted:Server=myServer;Database=myDatabase;User Id=myUsername;Password=myPassword;"
},
"key1": "value1",
"key2": "unencrypted:value2"
}

When your application runs, if it detects this, it encrypts the value and saves the encrypted value back to the JSON file so the file will look like:
{
"ConnectionStrings": {
"MyDB": "encrypted:npKy+h1OZb5LYt500EuotjPMflb+tg6TARUUJ3LYnb0E40W/YkOdc545PlMKd+dQl9lqZiYEQNvK3gk08tlKi2qJitXKXUTJdf0ANhgGtGM="
},
"key1": "value1",
"key2": "encrypted:sbv8Nz8MyyanNPRtlfCopw=="
}

The encrypted value will be decrypted automatically at the subsequent runs of your application.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.1.2 60 7/15/2019
1.1.1 54 7/14/2019
1.1.0 67 7/13/2019
1.0.0 108 7/11/2019