EncryptionUtils.Cryptography
1.0.0
dotnet add package EncryptionUtils.Cryptography --version 1.0.0
NuGet\Install-Package EncryptionUtils.Cryptography -Version 1.0.0
<PackageReference Include="EncryptionUtils.Cryptography" Version="1.0.0" />
<PackageVersion Include="EncryptionUtils.Cryptography" Version="1.0.0" />
<PackageReference Include="EncryptionUtils.Cryptography" />
paket add EncryptionUtils.Cryptography --version 1.0.0
#r "nuget: EncryptionUtils.Cryptography, 1.0.0"
#:package EncryptionUtils.Cryptography@1.0.0
#addin nuget:?package=EncryptionUtils.Cryptography&version=1.0.0
#tool nuget:?package=EncryptionUtils.Cryptography&version=1.0.0
ð EncryptionUtils
EncryptionUtils is a lightweight, modular cryptography framework for .NET â providing unified abstractions for encryption, hashing, and encryption-aware JSON serialization with minimal dependencies and maximum flexibility.
ð Overview
EncryptionUtils is built around a simple but powerful concept: abstraction first.
Every cryptographic algorithm, hasher, and JSON converter implements one of three interfaces:
IEncryptionAlgorithmIHasherIJsonConverter
This unified design allows you to:
- ð Swap algorithms at runtime with dependency injection
- ð§Đ Mix and match implementations
- âïļ Extend with your own algorithms easily
âïļ Installation
dotnet add package EncryptionUtils.Cryptography.Algorithms
dotnet add package EncryptionUtils.Serialization.TextJson
# or
dotnet add package EncryptionUtils.Serialization.Newtonsoft
ð Quick Start
Example 1 â General Project Usage (AES-GCM 256)
using EncryptionUtils.Cryptography.Algorithms;
// Base64 key and IV
var key = "bVd8bJcX7v3WyqfWAWp6xPq5L9Z4Hq0QOStvzQ7XjCk=";
var iv = "QmFzZTY0SVY=";
var aes = new AESGCM(key, iv);
string plainText = "Confidential message";
string encrypted = aes.Encrypt(plainText);
string decrypted = aes.Decrypt(encrypted);
Console.WriteLine($"Encrypted: {encrypted}");
Console.WriteLine($"Decrypted: {decrypted}");
Example 2 â Dependency Injection Setup (ASP.NET Core)
using EncryptionUtils.Cryptography.Algorithms;
using EncryptionUtils.Cryptography.Interfaces_Abstracts;
using Microsoft.Extensions.DependencyInjection;
var services = new ServiceCollection();
// Register AES-GCM 256 with DI
services.AddSingleton<IEncryptionAlgorithm>(_ =>
new AESGCM(
key: "bVd8bJcX7v3WyqfWAWp6xPq5L9Z4Hq0QOStvzQ7XjCk=",
iv: "QmFzZTY0SVY="));
var provider = services.BuildServiceProvider();
var aes = provider.GetRequiredService<IEncryptionAlgorithm>();
string data = "API secret";
string cipher = aes.Encrypt(data);
string plain = aes.Decrypt(cipher);
Console.WriteLine($"Decrypted: {plain}");
ð§Đ Key Components
| Project | Description |
|---|---|
| EncryptionUtils.Cryptography | Core interfaces and abstract classes |
| EncryptionUtils.Cryptography.Algorithms | AES (GCM/CBC), RSA, SHA, HMAC, Scrypt |
| EncryptionUtils.Serialization | [Encrypt] attribute + core serialization abstractions |
| EncryptionUtils.Serialization.TextJson | Integration with System.Text.Json |
| EncryptionUtils.Serialization.Newtonsoft | Integration with Newtonsoft.Json |
ð Encryption-Aware Serialization
Automatically encrypt and decrypt marked properties during JSON (de)serialization.
Example â Using System.Text.Json
using EncryptionUtils.Serialization.Attributes;
public class User
{
public string Name { get; set; }
[Encrypt]
public string Password { get; set; }
}
using EncryptionUtils.Serialization.TextJson;
using EncryptionUtils.Serialization.Core;
using EncryptionUtils.Cryptography.Algorithms;
var aes = new AESGCM(256);
var converter = new TextJsonConverter();
var serializer = new EncryptedJsonSerializer(converter, aes);
var user = new User { Name = "Alice", Password = "SuperSecret" };
string json = await serializer.SerializeAsync(user); // Password is encrypted
var restored = await serializer.DeserializeAsync<User>(json); // Password is decrypted
Example â Using Newtonsoft.Json
using EncryptionUtils.Serialization.Newtonsoft;
using EncryptionUtils.Serialization.Core;
using EncryptionUtils.Cryptography.Algorithms;
using EncryptionUtils.Serialization.Attributes;
public class Account
{
public string Username { get; set; }
[Encrypt]
public string ApiKey { get; set; }
}
var aes = new AESGCM(256);
var converter = new NewtonsoftJsonConverter();
var serializer = new EncryptedJsonSerializer(converter, aes);
var account = new Account { Username = "valadis", ApiKey = "TopSecretKey" };
string json = await serializer.SerializeAsync(account);
Console.WriteLine(json); // ApiKey is encrypted
var restored = await serializer.DeserializeAsync<Account>(json);
Console.WriteLine(restored.ApiKey); // decrypted back to "TopSecretKey"
ð§ Philosophy
- ðŠķ Lightweight: minimal dependencies, pure C#
- ð§Đ Modular: plug-and-play architecture
- ðĄ Flexible: your own algorithms can implement the same interfaces
- âïļ Consistent: identical usage patterns across all algorithm types
ðĶ Project Structure
EncryptionUtils/
âââ EncryptionUtils.Cryptography/
â âââ Interfaces_Abstracts/
âââ EncryptionUtils.Cryptography.Algorithms/
âââ EncryptionUtils.Serialization/
âââ EncryptionUtils.Serialization.TextJson/
âââ EncryptionUtils.Serialization.Newtonsoft/
âââ EncryptionUtils.Tests/
âïļ License
- Main projects: MIT License
- Algorithms project includes Scrypt.NET (Apache 2.0)
âĪïļ Contributing
Contributions and ideas are welcome!
Please open an issue or pull request on GitHub.
ðĻâðŧ Author
Valadis Pitsas
GitHub: @cpitsas
NuGet: EncryptionUtils.Cryptography
â TL;DR
A clean, consistent, and extensible cryptography abstraction layer for .NET â
simple to use, powerful to extend, and ready for production.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on EncryptionUtils.Cryptography:
| Package | Downloads |
|---|---|
|
EncryptionUtils.Serialization
Serializer agnostic property serialization functionality for encrypted properties. |
|
|
EncryptionUtils.Cryptography.Algorithms
Provides implementations of several cryptographic algorithms. Focused on simplicity and ease of use. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 319 | 10/10/2025 |