wan24-Crypto-NaCl 2.11.0

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

// Install wan24-Crypto-NaCl as a Cake Tool
#tool nuget:?package=wan24-Crypto-NaCl&version=2.11.0                

wan24-Crypto-NaCl

This library adopts NSec to wan24-Crypto and extends the wan24-Crypto library with these algorithms:

Algorithm ID Name
KDF
Argon2id 1 ARGON2ID

How to get it

This library is available as NuGet package.

Usage

In case you don't use the wan24-Core bootstrapper logic, you need to initialize the NaCl extension first, before you can use it:

wan24.Crypto.NaCl.Bootstrapper.Boot();

This will register the algorithms to the wan24-Crypto library.

To set NaCl defaults as wan24-Crypto defaults:

NaClHelper.SetDefaults();

Per default the current wan24-Crypto default will be set as counter algorithms to HybridAlgorithmHelper.

JSON configuration

You could implement a JSON configuration file using the AppConfig logic from wan24-Core, and the NaClCryptoAppConfig. There it's possible to define disabled algorithms, which makes it possible to react to an unwanted algorithm very fast, at any time and without having to update your app, for example. If you use an AppConfig, it could look like this:

public class YourAppConfig : AppConfig
{
    public YourAppConfig() : base() { }

    [AppConfig(AfterBootstrap = true, Priority = 20)]
    public CryptoAppConfig? Crypto { get; set; }

    [AppConfig(AfterBootstrap = true, Priority = 10)]
    public NaClCryptoAppConfig? NaCl { get; set; }
}

await AppConfig.LoadAsync<YourAppConfig>();

NOTE: A NaClCryptoAppConfig should be applied before a CryptoAppConfig. For this reason the example defines a priority in the AppConfigAttribute.

In the config.json in your app root folder:

{
    "NaCl":{
        ...
    }
}

Anyway, you could also place and load a NaClCryptoAppConfig in any configuration which supports using that custom type.

Argon2id

A simple KDF operation example:

(byte[] stretchedPwd, byte[] salt) = KdfArgon2IdAlgorithm.Instance.Stretch(pwd, len: 32);

To use Argon2id as default KDF algorithm:

KdfHelper.DefaultAlgorithm = KdfArgon2IdAlgorithm.Instance;

You may specify Argon2id specific options using the KdfArgon2IdOptions, which cast implicit to/from a JSON string. The default options are the OWASP recommendations (46M memory usage):

(byte[] stretchedPwd, byte[] salt) = pwd.Stretch(len: 32, options: new KdfArgon2IdOptions()
	{
		// Configure the options here
	});// KdfArgon2IdOptions cast implicit to CryptoOptions

Or when using CryptoOptions:

CryptoOptions options = new()
{
	KdfAlgorithm = KdfArgon2IdAlgorithm.ALGORITHM_NAME,
	KdfIterations = KdfArgon2IdAlgorithm.Instance.DefaultIterations,
	KdfOptions = new KdfArgon2IdOptions()
	{
		// Configure the options here
	}
};
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
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.11.0 95 10/27/2024
2.10.0 79 9/21/2024
2.9.0 106 9/9/2024
2.8.0 123 8/16/2024
2.7.1 77 7/13/2024
2.7.0 104 7/6/2024 2.7.0 is deprecated because it is no longer maintained.
2.6.0 103 6/22/2024
2.5.0 116 6/16/2024
2.4.0 131 3/9/2024
2.3.0 131 3/2/2024
2.2.0 114 2/24/2024
2.1.2 112 2/17/2024
2.1.1 129 2/11/2024
2.1.0 112 2/10/2024
2.0.0 114 1/21/2024
1.4.2 156 11/11/2023
1.4.1 147 10/21/2023
1.4.0 138 10/15/2023
1.3.0 127 10/8/2023
1.2.0 132 10/1/2023
1.1.0 118 9/19/2023
1.0.0 113 9/16/2023