NSec is a modern and easy-to-use cryptographic library for .NET Core based on libsodium.


The following C# example shows NSec can be used to sign some data with Ed25519 and verify the signature:

// select the Ed25519 signature algorithm
var algorithm = SignatureAlgorithm.Ed25519;

// create a new key pair
using (var key = Key.Create(algorithm))
    // generate some data to be signed
    var data = Encoding.UTF8.GetBytes("Use the Force, Luke!");

    // sign the data with the private key
    var signature = algorithm.Sign(key, data);

    // verify the data with the signature and the public key
    if (algorithm.Verify(key.PublicKey, data, signature))


$ dotnet add package NSec.Cryptography --version 18.6.0

NSec runs on .NET Core 2.1, 2.0, and 1.1 on Windows, Linux and Mac, and requires a C# 7.2 (or later) compiler. See Installation for more details.


API Reference


NSec is an open source project. Contributions to the code or documentation are highly welcome.

The development of NSec takes place in its GitHub repository. The easiest way to contribute is by submitting a pull request. Please ask before making a significant pull request (e.g., implementing any new features). If you’ve found a problem with NSec, please open an issue. Feature requests and questions are welcome, too.


“Cryptography is not magic pixie dust that you can sprinkle on a system to make it secure.”

NSec aims to provide careful abstractions to make the work with modern cryptographic primitives relatively easy and pain-free. However, the primitives are not very useful by themselves and need to be combined into higher-level security protocols (such as TLS or CBOR Web Token). Don’t roll your own security protocols.


NSec is licensed under the MIT license.