Skip to content
Effortless .Net Encryption is a library that is written in C#, and provides: Rijndael encryption/decryption, Hashing and Digest creation/validation and Password & Salt creation.
C# Batchfile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Effortless.Net.Encryption.Tests.Unit Add ability to specify KeySize and BlockSize Oct 18, 2019
Properties
ThirdParty Added assembly versioning Aug 13, 2012
.gitignore
Bytes.cs
DiffieHellman.cs Include MIT Licence Aug 1, 2019
Digest.cs Add ability to specify KeySize and BlockSize Oct 18, 2019
DigitalSignature.cs Add DigitalSignature Apr 9, 2018
Effortless.Net.Encryption.csproj
Effortless.Net.Encryption.nuspec
Effortless.Net.Encryption.pfx Added assembly signing Aug 13, 2012
Effortless.Net.Encryption.sln Removed Pex & Moles unit tests Dec 22, 2014
Hash.cs
LICENSE Initial commit Feb 23, 2016
README.md
Strings.cs
nuget-update.bat Project creation Aug 10, 2012
pack.bat

README.md

Effortless .Net Encryption

Project Description

Effortless .Net Encryption is a library that is written in C# and provides:

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

Nuget

https://nuget.org/packages/Effortless.Net.Encryption/

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

PM> Install-Package Effortless.Net.Encryption

Overview

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);

// Digital Signatures
var hash = Hash.Create(HashType.SHA256, "Hello", string.Empty)
var ds = new DigitalSignature();
ds.AssignNewKey();
var signature = ds.SignData(hash);
var result = ds.VerifySignature(hash, signature);
Assert.IsTrue(result);

// Diffie Hellman
var alice = new DiffieHellman();
var bob = new DiffieHellman();
// Bob uses Alice's public key to encrypt his message.
var secretMessage = bob.Encrypt(alice, "Hello");
// Alice uses Bob's public key and IV to decrypt the secret message.
var decryptedMessage = alice.Decrypt(bob, secretMessage);
Assert.AreEqual("Hello", decryptedMessage);
You can’t perform that action at this time.