Monocypher 0.3.0

.NET 6.0 .NET Standard 2.0
Install-Package Monocypher -Version 0.3.0
dotnet add package Monocypher --version 0.3.0
<PackageReference Include="Monocypher" Version="0.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Monocypher --version 0.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Monocypher, 0.3.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// 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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Monocypher<font color="FF8C44">.NET</font> Build Status Build Status NuGet

<img align="right" width="160px" height="160px" src="">

Monocypher.NET is a managed wrapper around Monocypher cryptographic library.

The current native version of Monocypher used by Monocypher.NET is 3.1.2


  • Provides the entire native Monocypher API in an efficient 1-to-1 mapping:
    • Authenticated Encryption (RFC 8439 with XChacha20 and Poly1305)
    • Hashing (Blake2b)
    • Password Key Derivation (Argon2i)
    • Key Exchange (X25519)
    • Public Key Signatures (EdDSA (RFC 8032) with Blake2b and edwards25519)
    • ...and more...
  • Each raw native function is duplicated with a more friendly API using Span/ReadOnlySpan parameters.
  • Compatible with .NET 6.0+ and .NET Standard 2.0+


Example of using the crypto_lock API

// Use static at the beginning of your file to
// import functions
using static Monocypher.Monocypher;

// ...

// Message authentication code
Span<byte> mac = stackalloc byte[16];
// Encrypted message
Span<byte> cipherText = stackalloc byte[16];
// Secret message
Span<byte> inputText = stackalloc byte[16];
inputText[0] = (byte)'a';
inputText[1] = (byte)'b';
inputText[2] = (byte)'c';
inputText[3] = (byte)'d';

// Random, secret session key
Span<byte> key = stackalloc byte[32];
// Use only once per key
Span<byte> nonce = stackalloc byte[24];

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[16], uint8_t *cipher_text, const uint8_t key[32], const uint8_t nonce[24], 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:

  • win-x64, win-x86, win-arm64, win-arm
  • linux-x64, linux-arm64, linux-arm
  • osx-x64, osx-arm64


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


Monocypher.NET is just a wrapper and is entirely relying on the Monocypher C implementation developed by Loup Vaillant.


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
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
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
0.3.0 168 4/10/2022
0.2.1 283 2/27/2021
0.2.0 155 2/20/2021
0.1.2 151 2/13/2021
0.1.1 149 2/13/2021
0.1.0 139 2/12/2021