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
<PackageReference Include="Security.Encryption.AES" Version="1.0.2" />
<PackageVersion Include="Security.Encryption.AES" Version="1.0.2" />
<PackageReference Include="Security.Encryption.AES" />
paket add Security.Encryption.AES --version 1.0.2
#r "nuget: Security.Encryption.AES, 1.0.2"
#:package Security.Encryption.AES@1.0.2
#addin nuget:?package=Security.Encryption.AES&version=1.0.2
#tool nuget:?package=Security.Encryption.AES&version=1.0.2
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
SecureEncryptionBuilderto 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 | Versions 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. |
-
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.