Skip to content

Simple library to do Authenticated Encryption in an opinionated way

License

Notifications You must be signed in to change notification settings

trustpilot/nuget-authenticated-encryption

Repository files navigation

Authenticated Encryption

This library combines the .NET built-in AES and HMAC algorithms to provide an easy-to-use interface for doing authenticated encryption. The library is based on this Gist by James Tuley: https://gist.github.com/jbtule/4336842, but modified slightly to only support the key based versions. Also it does not use the GCM version currently, so there are no external dependencies.

Build Status

Build status

Installation

Install via NuGet:

Install-Package AuthenticatedEncryption

More information

The library consists of a single static class. This makes it very easy to use. It uses Authenticated Encryption with Associated Data (AEAD), using the approach called “Encrypt then MAC” (EtM). It uses one key for the encryption part (cryptkey) and another key for the MAC part (authkey).

This is a simple example of encrypting and decrypting some string:

using AuthenticatedEncryption;

const string Input = "this is a test input string";
var cryptKey = Encryption.NewKey();
var authKey = Encryption.NewKey();

var cipherText = Encryption.Encrypt(Input, cryptKey, authKey);
var plainText = Encryption.Decrypt(cipherText, cryptKey, authKey);

Maintainer(s)

About

Simple library to do Authenticated Encryption in an opinionated way

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages