Skip to content
libsodium based .NETstandard crypto library.
Branch: master
Clone or download
Andreas Hellenbrand
Andreas Hellenbrand Hello World
Latest commit b273305 Apr 11, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
docu Hello World Apr 11, 2019
src/andhell.crypto Hello World Apr 11, 2019
.gitignore Hello World Apr 11, 2019
LICENSE Initial commit Apr 11, 2019 Hello World Apr 11, 2019

Cryptography Library with .NET Standard 2.0 and libsodium.

What is this?

This library aims to make the use of cryptography easier. To do so, this Project builds around libsodium, but, for example, hides every byte[] for a Key or a Hash inside a container class. To get an impression, see the Examples below.

To make the entry even simpler, take a look at the "By Usecase" documentation.

If already know how to use cryptography and need more flexibility to build strong protocols, you are better of with using libsodium (or another library) directly.


Implementation with libsodium.


  • Password Hashing
  • General Hashing
  • Keyed Hashing
  • Password based Key Derivation not ready
  • Symmetric Encryption and Decryption
    • Authenticated Encryption
  • Asymmetric Encryption and Decryption

Tools and Build

The Solution can be opened with Visual Studio 2017 (and later) or VS Core. It is based .NET Standard 2.0. The MSTest Unit Tests are based on .NET Core 2.1

Build on Linux:

cd src/andhell.crypto
dotnet build



Store and Verify Password

// Create a Password object for the string
var password = new Password("Correct Horse Battery Staple");
// Hash the Pasword to get a storable data
ISecuredPassword storablePassword = password.Storable();           
// To Verify
if (storablePassword.Verify(password))
    Console.WriteLine("Password matched");

Generic Hash

var MESSAGE = "eine kuh macht muh, viele kühe machen mühe"
// Create a new HashBox
IHashBox hashBox = new HashBox();
// Compute the Hash
var result = hashBox.Compute(MESSAGE);
// Verify if the hash is the hash MESSAGE
if (result.Verify(MESSAGE)) 
    Console.WriteLine("Hash matched!");

Encrypt and Decrypt Text with a Symmetric Key

var MESSAGE = "eine kuh macht muh, viele kühe machen mühe"
// Create a new Symmetric Key
var key = new Key();
// Create a locker with this key
var locker = new SecretLocker(key);
// Encrypt the Text
var ciphertext = locker.Lock(MESSAGE);
// Decrypt the Text
var plaintext = locker.UnlockString(ciphertext);

// clear keys from Memory

Encrypt and Decrypt Text with a Asymmetric KeyPair

var MESSAGE = "eine kuh macht muh, viele kühe machen mühe"
// Create a KeyPair for Alice and Bob
var AliceKeys = new KeyPair();
var BobKeys = new KeyPair();

// Create a Locker to encrypt Messages from Alice to Bob
var locker = new SharedLocker(recieverPubKey: BobKeys.Public, senderPrivKey: AliceKeys.Secret);
// Encrypt the Message
var locked = locker.Lock(MESSAGE);

// Bob can then decrypt the Message
var unlocked = locked.UnlockString(AliceKeys.Public, BobKeys.Secret);

// clear keys from Memory


You can’t perform that action at this time.