SecureLocalStorage 2.0.0

dotnet add package SecureLocalStorage --version 2.0.0                
NuGet\Install-Package SecureLocalStorage -Version 2.0.0                
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="SecureLocalStorage" Version="2.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SecureLocalStorage --version 2.0.0                
#r "nuget: SecureLocalStorage, 2.0.0"                
#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.
// Install SecureLocalStorage as a Cake Addin
#addin nuget:?package=SecureLocalStorage&version=2.0.0

// Install SecureLocalStorage as a Cake Tool
#tool nuget:?package=SecureLocalStorage&version=2.0.0                

Secure Local Storage

alt text

Secure Local Storage is a simple package for .NET that allows you to safely store information locally, allowing you to select whether the information will only be decryptable on the computer where it was created, or if it can be shared between several computers.

Mainly it offers you the option of storing information or sensitive settings and obtaining it from the same or another application.

Installation

Use the nuget package manager to install SecureLocalStorage.

Package Manager:

Install-Package SecureLocalStorage -Version 2.0.0

.NET CLI:

dotnet add package SecureLocalStorage --version 2.0.0

Caveat:

Version 1 does not support MacOs and Linux, so please upgrade to version 2 if you are encrypting local data in a cross-platform project.

Since version 2, both Mac and Linux and Windows have the ability to store fully encrypted local files and data on the machine where your software runs.

Simple Usage

Instantiate the class with the default settings:

var config = new DefaultLocalStorageConfig();
var storage = new SecureLocalStorage.SecureLocalStorage(config);

Add data to storage:

storage.Set("Example", "Hello world.");
//If key exists content will replaced.

Add custom data to storage:

var userExample = new UserExample {Name = "Juan", Verified = true};
storage.Set("User", userExample);

Get data from storage:

string data = storage.Get("Example"); //Hello world

Get custom data from storage:

var data = storage.Get<UserExample>("User"); //{Name = "Juan", Verified = true}

Remove data from storage:

storage.Remove("User");

Check if data exists on storage

var exists = storage.Exists("User");

Advanced Usage

By default, the information is encrypted with the values of the machine that runs the application and it is only possible to manipulate the data in the same environment, that is, information stored between devices cannot be stolen.

Optionally you can configure where that information is stored and how it is encrypted.

Custom configuration

The information is stored by default in Environment.SpecialFolder.ApplicationData.

and its hierarchy is as follows:

%SpecialFolder% / Your_App_Name / default.

Change default app name:
config = new CustomLocalStorageConfig(null, "DotnetsaferTesting").WithDefaultKeyBuilder();

Make sure the name is unique to your application, or it could create conflicts with other applications.

Change default path:
config = new CustomLocalStorageConfig(@"current/default", "DotnetsaferTesting").WithDefaultKeyBuilder();
Change default encryption key:

If you don't want the encryption key to be unique values of the device, you can set one yourself.

config = new CustomLocalStorageConfig(@"current/default", "DotnetsaferTesting", "secret1234");

If you want to add a dynamic key you can override the BuildLocalSecureKey method:

config.BuildLocalSecureKey = () => Guid.NewGuid().ToString();

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

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. 
.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. 
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.0.0 4,487 1/8/2023
1.0.0 487 3/31/2021