dotnet add package Monocypher --version 0.3.0
NuGet\Install-Package Monocypher -Version 0.3.0
<PackageReference Include="Monocypher" Version="0.3.0" />
paket add Monocypher --version 0.3.0
#r "nuget: Monocypher, 0.3.0"
// Install Monocypher as a Cake Addin #addin nuget:?package=Monocypher&version=0.3.0 // Install Monocypher as a Cake Tool #tool nuget:?package=Monocypher&version=0.3.0
<img align="right" width="160px" height="160px" src="https://raw.githubusercontent.com/xoofx/Monocypher.NET/master/img/monocypher_dotnet.png">
Monocypher.NET is a managed wrapper around Monocypher cryptographic library.
The current native version of Monocypher used by Monocypher.NET is
- Provides the entire native Monocypher API in an efficient 1-to-1 mapping:
- Authenticated Encryption (
- Hashing (
- Password Key Derivation (
- Key Exchange (
- Public Key Signatures (
8032) with Blake2b and
- ...and more...
- Authenticated Encryption (
- Each raw native function is duplicated with a more friendly API using
- Compatible with
.NET Standard 2.0+
Example of using the
// Use static at the beginning of your file to // import functions using static Monocypher.Monocypher; // ... // Message authentication code Span<byte> mac = stackalloc byte; // Encrypted message Span<byte> cipherText = stackalloc byte; // Secret message Span<byte> inputText = stackalloc byte; inputText = (byte)'a'; inputText = (byte)'b'; inputText = (byte)'c'; inputText = (byte)'d'; // Random, secret session key Span<byte> key = stackalloc byte; RNGCryptoServiceProvider.Fill(key); // Use only once per key Span<byte> nonce = stackalloc byte; RNGCryptoServiceProvider.Fill(nonce); crypto_lock(mac, cipherText, key, nonce, inputText); // mac contains the authenticated code // cipherText contains the encrypted message
Because Monocypher.NET is a raw wrapper of Monocypher, the excellent Monocypher manual can be used to easily dig into the API.
For example, the
crypto_lock C API defined like this:
void crypto_lock(uint8_t mac, uint8_t *cipher_text, const uint8_t key, const uint8_t nonce, const uint8_t *plain_text, size_t text_size);
is exposed with the following 2 functions in Monocypher.NET, one being a strict equivalent and the other using Span/ReadOnlySpan
// Pure translation of the C API public static void crypto_lock(ref Byte16 mac, IntPtr cipher_text, in Byte32 key, in Byte24 nonce, IntPtr plain_text, Monocypher.size_t text_size); // API using Span/ReadOnlySpan public static void crypto_lock(Span<byte> mac, Span<byte> cipher_text, ReadOnlySpan<byte> key, ReadOnlySpan<byte> nonce, ReadOnlySpan<byte> plain_text)
Monocypher.NET is supported on the following platforms:
The primary usage for Monocypher is for resources constrained platforms (e.g micro-controllers) where the code size and performance must be balanced.
For .NET, this constraint might be less important, so if you are looking for the fastest cryptographic library, Monocypher.NET might not be the best candidate.
That being said, if you are building an IoT project using the C Monocypher and you want to communicate with a .NET project, you might want to make sure that the cryptographic library used is the same between the client and the server (even though that's not strictly required). In that case Monocypher.NET is a good compromise.
How to Build?
You need to install the .NET 6 SDK. Then from the root folder:
$ dotnet build src -c Release
In order to rebuild the native binaries, you need to run the build scripts from ext
This software is released under the BSD-Clause 2 license.
The native Monocypher is released with the following BSD-Clause 2 license terms.
Alexandre Mutel aka xoofx.
|Product||Versions Compatible and additional computed target framework versions.|
|.NET||net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. 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-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.|
This package is not used by any NuGet packages.
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on Monocypher:
A simple, modern, and secure encryption and signing tool that aims to be a better version of age and Minisign.