Project Description

Effortless .Net Encryption is a library that is written in C# 4.0, contains 68 unit tests, 190 Pex unit tests, and provides:

  • Rijndael encryption/decryption.
  • Hashing and Digest creation/validation.
  • Password and salt creation.


To install Effortless.Net.Encryption, run the following command in the Package Manager Console

PM> Install-Package Effortless.Net.Encryption


  1. Make sure you have Nuget package manager installed
  2. In Visual Studio, tick the option Tools->Options->Package Manager->General->Allow Nuget to download missing packages during build.
  3. Run the nuget-update.bat script to install any missing packages.
  4. Compile.


The project is split into four main areas

  • Strings – Encryption/Decryption/Password and Salt generation
  • Hash – Creation and verification of hashes using MD5, SHA1, SHA256, SHA384, SHA512.
  • Digest – Creation and verification of digests (data + hash). Plus two handy ToString() and CreateFromString() functions which come in handy if you want to store data in a Cookie.
  • Bytes – The core of the library. This uses the Rijndael algorithm and works at the byte[] level for most functions.
Some examples
// Creating passwords & salts
string password = Strings.CreatePassword(15, true);
string salt = Strings.CreateSalt(20);

// Encrypting/decrypting strings
byte[] key = Bytes.GenerateKey();
byte[] iv = Bytes.GenerateIV();
string encrypted = Strings.Encrypt("Secret", key, iv);
string decrypted = Strings.Decrypt(encrypted, key, iv);
Assert.AreEqual("Secret", decrypted);

// Hashes
string hash = Hash.Create(HashType.SHA512, "Hello", string.Empty, false);

// Digests
var d1 = Digest.Create(HashType.MD5, "Hello", string.Empty);
string cookieString = d1.ToString();
var d2 = Digest.CreateFromString(cookieString, string.Empty);
Assert.AreEqual(d1.Data, d2.Data);
Assert.AreEqual(d1.Hash, d2.Hash);

// Bytes
byte[] key = Bytes.GenerateKey();
byte[] iv = Bytes.GenerateIV();
var data = new byte[1024];
new RNGCryptoServiceProvider().GetBytes(data); // Random data
byte[] encrypted = Bytes.Encrypt(data, key, iv);
byte[] decrypted = Bytes.Decrypt(encrypted, key, iv);
Assert.AreEqual(data, decrypted);


See the documentation tab for an example of each function available in this library.

Last edited Aug 28, 2012 at 4:29 PM by SimonHughes, version 18