SoftCircuits.WinSettings
3.0.1
Prefix Reserved
See the version list below for details.
dotnet add package SoftCircuits.WinSettings --version 3.0.1
NuGet\Install-Package SoftCircuits.WinSettings -Version 3.0.1
<PackageReference Include="SoftCircuits.WinSettings" Version="3.0.1" />
paket add SoftCircuits.WinSettings --version 3.0.1
#r "nuget: SoftCircuits.WinSettings, 3.0.1"
// Install SoftCircuits.WinSettings as a Cake Addin #addin nuget:?package=SoftCircuits.WinSettings&version=3.0.1 // Install SoftCircuits.WinSettings as a Cake Tool #tool nuget:?package=SoftCircuits.WinSettings&version=3.0.1
EasyEncryption
Install-Package SoftCircuits.EasyEncryption
The .NET Framework provides a number of encryption routines. However, these routines generally require a bit of work to set up correctly. Use EasyEncryption
to make these encryption routines more easily accessible.
Encrypting a String
The Encrypt()
method can be used to encrypt a string. Use DecryptString()
to decrypt the string back to the original.
Encryption encrypt = new Encryption("Password123", EncryptionAlgorithm.TripleDes);
string original = "This is my message";
string cipher = encrypt.Encrypt(original);
string result = encrypt.DecryptString(cipher);
Debug.Assert(result == message);
Encrypting other Types
The Encrypt()
method is overloaded to encrypt many different data types. When decrypting, you must use the decryption method specific to the data type you are decrypting. This example encrypts an int
and double
value.
Encryption encrypt = new Encryption("Password123", EncryptionAlgorithm.TripleDes);
int originalInt = 55;
double originalDouble = 123.45;
string cipherInt = encrypt.Encrypt(originalInt);
string cipherDouble = encrypt.Encrypt(originalDouble);
int resultInt = encrypt.DecryptInt32(cipherInt);
double resultDouble = encrypt.DecryptDouble(cipherDouble);
Debug.Assert(resultInt == originalInt);
Debug.Assert(resultDouble == originalDouble);
Streams
EasyEncryption
also provides the streaming classes EncryptionWriter
and EncryptionReader
. These classes work well when encrypting to (or decrypting from) files.
The following example uses the CreateStreamWriter()
to encrypt a number of integer values to a file.
Encryption encrypt = new Encryption("Password123", EncryptionAlgorithm.TripleDes);
int[] intValues = { 123, 88, 902, 27, 16, 4, 478, 54 };
using (EncryptionWriter writer = encrypt.CreateStreamWriter(path))
{
for (int i = 0; i < intValues.Length; i++)
writer.Write(intValues[i]);
}
Use the CreateStreamReader()
method to decrypt those integer values from the file.
Encryption encrypt = new Encryption("Password123", EncryptionAlgorithm.TripleDes);
int[] intValues = new int[8];
using (EncryptionReader reader = encrypt.CreateStreamReader(path))
{
for (int i = 0; i < intValues.Length; i++)
intValues[i] = reader.ReadInt32();
}
Also, the CreateStreamWriter()
and CreateStreamReader()
methods are overloaded to accept a stream argument, allowing you to use custom streams. For example, you could use a MemoryStream
to encrypt data to memory. This is demonstrated in the following example. It also uses the static method EncodeBytesToString()
method to convert the results to a string. (Note that there is also a corresponding static DecodeBytesFromString()
method.)
Encryption encrypt = new Encryption("Password123", EncryptionAlgorithm.TripleDes);
using (MemoryStream stream = new MemoryStream())
using (EncryptionWriter writer = encrypt.CreateStreamWriter(stream))
{
writer.Write("ABC");
writer.Write(123);
writer.Write(123.45);
string s = Encryption.EncodeBytesToString(stream.ToArray());
}
Note that the streaming classes are actually the most efficient way to encrypt and decrypt data. In fact the Encrypt()
and decryption methods create an instance of EncryptionWriter
internally (using a MemoryStream
), even when only encrypting or decrypting a single byte.
In addition, it should be pointed out that the encrypted results produced by these routines include embedded meta data, making the encrypted data slightly larger than it would otherwise be. However, when encrypting to a stream, this data would only be stored once regardless of the number of values added to the stream. The takeaway is that you can use the Encrypt()
method for a simple encryption, but should use the streaming classes for anything more complex.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net5.0-windows7.0 is compatible. 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. net6.0-windows7.0 is compatible. 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
- Microsoft.Win32.Registry (>= 5.0.0)
- SoftCircuits.EasyEncryption (>= 2.0.0)
-
net5.0-windows7.0
- Microsoft.Win32.Registry (>= 5.0.0)
- SoftCircuits.EasyEncryption (>= 2.0.0)
-
net6.0-windows7.0
- Microsoft.Win32.Registry (>= 5.0.0)
- SoftCircuits.EasyEncryption (>= 2.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Added support for enum settings; Added support for .NET 6.0; Miscellaneous fixes and clean up.