Security.Encryption.AES 1.0.2

dotnet add package Security.Encryption.AES --version 1.0.2
                    
NuGet\Install-Package Security.Encryption.AES -Version 1.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Security.Encryption.AES" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Security.Encryption.AES" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Security.Encryption.AES" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Security.Encryption.AES --version 1.0.2
                    
#r "nuget: Security.Encryption.AES, 1.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Security.Encryption.AES@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Security.Encryption.AES&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Security.Encryption.AES&version=1.0.2
                    
Install as a Cake Tool

Security.Encryption.AES

Security.Encryption.AES is a .NET library providing easy-to-use, secure AES encryption and decryption utilities. It supports both AES-GCM (Galois/Counter Mode) and AES-CBC (Cipher Block Chaining) modes, making it suitable for a wide range of cryptographic scenarios.

Table of Content

Functionalities

  • AES-GCM Encryption/Decryption: Authenticated encryption for modern security needs.
  • AES-CBC Encryption/Decryption: Traditional block cipher mode with PKCS7 padding.
  • Key and IV management: Secure handling of cryptographic keys and initialization vectors.
  • Dynamic Key usage: You provide the key to be used, so the key is not stored for other purposes or generated.
  • Easy to use: Easy integration with your .NET projects.
  • Builder Pattern: Use the SecureEncryptionBuilder to configure and instantiate ciphers.

How to Install

Add the library to your project using the .NET CLI:

dotnet add package Security.Encryption.AES

Usage / Implementation

1. Create an Encryptor

using Security.Encryption.AES;
using Security.Encryption.AES.Enums;

byte[] key = Convert.FromBase64String("your-base64-key-here");

var cipher = new SecureEncryptionBuilder()
    .WithKey(key)
    .WithMode(AesEncryptionMode.GCM)
    .Build();

2. Encrypt Data

string plainText = "Sensitive Data";
byte[] encrypted = cipher.Encrypt(plainText);

3. Decrypt Data

string decrypted = cipher.Decrypt(encrypted);

Example with CBC Mode

var cbcCipher = new SecureEncryptionBuilder()
    .WithKey(key)
    .WithMode(AesEncryption.CBC)
    .Build();

byte[] encrypted = cbcCipher.Encrypt("Another secret");
string decrypted = cbcCipher.Decrypt(encrypted);

For more details see the interfaces ISecureEncryption and IGcmSecureEncryption.

Contribution

Contributions are welcome! Please fork the repository and submit a pull request.

Test

This project uses xUnit for unit testing.

To run the tests:

cd src/Security.Encryption.AES.Tests
dotnet test

Test files are located in the src/Security.Encryption.AES.Tests directory and cover all the functionalities.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.2 1,197 7/25/2025
1.0.1 246 7/20/2025
1.0.0 164 7/14/2025