Armala.FConfig
23.1.6.1128
dotnet add package Armala.FConfig --version 23.1.6.1128
NuGet\Install-Package Armala.FConfig -Version 23.1.6.1128
<PackageReference Include="Armala.FConfig" Version="23.1.6.1128" />
paket add Armala.FConfig --version 23.1.6.1128
#r "nuget: Armala.FConfig, 23.1.6.1128"
// Install Armala.FConfig as a Cake Addin #addin nuget:?package=Armala.FConfig&version=23.1.6.1128 // Install Armala.FConfig as a Cake Tool #tool nuget:?package=Armala.FConfig&version=23.1.6.1128
FConfig
FConfig is a configuration management library for .NET applications. It provides an easy way to store and retrieve configuration values in a file, with the option to use AES encryption for added security.
Installation
PackageManager
NuGet\Install-Package Armala.FConfig
.NET CLI
dotnet add package Armala.FConfig
Dependencies
FConfig depends on the following libraries:
- System.Security.Cryptography.Algorithms (≥ 4.3.0) These dependencies will be automatically installed when you install FConfig.
ConfigManager
This is a C# class for managing a configuration file using the AES algorithm for optional encryption.
Methods
Construct(string configurationPath, string secretKey = null, bool useEncryption = true)
Constructs a new instance of the ConfigManager class.
The configuration path, secret key, and use of encryption can be specified. If the secret key is not provided or is not 32 characters in length, an ArgumentException will be thrown.
If the configuration file at the specified path does not exist, an empty file will be created. The global variables ConfigurationPath, Encrypt, and SecretKey will be set, and the Configuration dictionary will be populated with the data from the configuration file. If the file is empty, the Configuration dictionary will be initialized as an empty dictionary. If encryption is enabled, the data will be decrypted before being deserialized into the Configuration dictionary. The OnConfigurationLoaded event will be raised after the configuration has been loaded.
Get<T>(string identifier, T fallback = default)
Gets the configuration value with the specified identifier. If the value is not found or cannot be converted to the specified type, the fallback value will be returned and set as the value for the specified identifier.
Set<T>(string identifier, T newValue)
Overwrites the specified configuration value in the Configuration dictionary and flushes the configuration bytes to a file.
Remove(string identifier)
Removes the configuration value with the specified identifier from the Configuration dictionary and saves the updated configuration to the configuration file.
Properties
Configuration
A Dictionary<string, object>
that contains the configuration data.
ConfigurationPath
A string containing the full path to the configuration file.
Encrypt
A bool indicating whether the configuration file is encrypted.
SecretKey
A string containing the secret key used for encryption.
Events
OnConfigurationLoaded(Dictionary<string, object> configuration)
This event is raised after the configuration has been loaded. The configuration parameter contains the Configuration dictionary.
Examples
FConfig.Construct("C:\\my-config-folder", "my-secret-key", true);
// Get the value of the "database-password" configuration key
string password = FConfig.Get<string>("database-password", "fallback value");
// Set the value of the "api-key" configuration key
FConfig.Set("api-key", "abc123");
// Remove the "api-key" configuration element
FConfig.Remove("api-key");
ByteEncryption
This is a C# class for encrypting and decrypting byte arrays using the AES algorithm.
Methods
Encrypt(byte[] rawBytes, string secretKey)
Encrypts the given raw bytes using the specified password.
Decrypt(byte[] secretInput, string password = null)
Decrypts the given encrypted bytes using the specified password.
Encrypt(byte[] rawBytes, byte[] salt, bool useMd5)
Encrypts the given raw bytes. An optional salt can be provided for encryption, and the use of MD5 can be specified.
Decrypt(byte[] secretInput, byte[] salt, bool useMd5)
Decrypts the given encrypted bytes. The salt and use of MD5 that were used for encryption must be provided.
Examples
byte[] rawBytes = Encoding.UTF8.GetBytes("Hello, world!");
// Encrypt the raw bytes
byte[] encryptedBytes = ByteEncryption.Encrypt(rawBytes, "my-secret-key");
// Decrypt the encrypted bytes
byte[] decryptedBytes = ByteEncryption.Decrypt(encryptedBytes, "my-secret-key");
// Convert the decrypted bytes back to a string and print it
string decryptedString = Encoding.UTF8.GetString(decryptedBytes);
Console.WriteLine(decryptedString); // Outputs: "Hello, world!"
License
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. |
.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 | net461 was computed. 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. |
-
.NETStandard 2.0
- No dependencies.
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 |
---|---|---|
23.1.6.1128 | 813 | 1/6/2023 |
23.1.1.733 | 793 | 1/1/2023 |
23.1.1.715 | 756 | 1/1/2023 |
22.12.30.1030 | 844 | 12/30/2022 |
22.12.19.719 | 842 | 12/19/2022 |