SimpleEncryption 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package SimpleEncryption --version 1.0.2                
NuGet\Install-Package SimpleEncryption -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="SimpleEncryption" Version="1.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SimpleEncryption --version 1.0.2                
#r "nuget: SimpleEncryption, 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.
// Install SimpleEncryption as a Cake Addin
#addin nuget:?package=SimpleEncryption&version=1.0.2

// Install SimpleEncryption as a Cake Tool
#tool nuget:?package=SimpleEncryption&version=1.0.2                

SimpleEncryption

SimpleEncryption is a modular library for cryptographic operations, designed to make encryption, hashing, and key derivation simple, flexible, and efficient.


✨ Features

  • 🔒 Encryption:
    • AES (256-bit) with configurable cipher modes and padding.
    • ChaCha20-Poly1305 for authenticated encryption.
  • 🔑 Hashing:
    • Secure hashing algorithms: SHA-256 and SHA-512.
  • 🧩 Key Derivation:
    • PBKDF2 key derivation.
  • ⚙️ Salt and Nonce Generation:
    • Generate secure salts and nonces dynamically.
  • 💡 Thread-safe and configurable.

📦 Installation

Install SimpleEncryption via NuGet:

dotnet add package SimpleEncryption

📚 Overview

🔒 AES Encryption

Encrypt and decrypt strings and byte arrays using AES (256-bit):

using SimpleEncryption.Encryption;

byte[] key = Aes.GenerateKey("password", "salt");
byte[] iv = Aes.GenerateIv("password", "salt");

string encrypted = Aes.Encrypt("Hello, World!", key, iv);
string decrypted = Aes.Decrypt(encrypted, key, iv);

Console.WriteLine($"Decrypted: {decrypted}");

ChaCha20-Poly1305 Encryption

Lightweight and secure encryption with associated data (AAD):

using SimpleEncryption.Encryption;

byte[] key = ChaCha20.GenerateKey("password", "salt");
byte[] nonce = ChaCha20.GenerateNonce();

string encrypted = ChaCha20.Encrypt("Hello, World!", key, nonce);
string decrypted = ChaCha20.Decrypt(encrypted, key);

Console.WriteLine($"Decrypted: {decrypted}");

🔑 Hashing (SHA-256 and SHA-512)

Hash strings securely with or without salt:

using SimpleEncryption.Hashing;

string sha256Hash = Sha256.Hash("password");
string sha512Hash = Sha512.Hash("password");

Console.WriteLine($"SHA-256 Hash: {sha256Hash}");
Console.WriteLine($"SHA-512 Hash: {sha512Hash}");

🧩 Pbkdf2 Key Derivation

Derive secure keys with Argon2 (i, d, id):

using SimpleEncryption.Derivation;

string Pbkdf2Key = Pbkdf2.DeriveKey("password", Pbkdf2.GenerateSalt(), keyLength: 32);
Console.WriteLine($"Pbkdf2 Derived Key: {Pbkdf2Key}");

🤝 Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request on GitHub.


📜 License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-android34.0 is compatible.  net8.0-browser was computed.  net8.0-browser1.0 is compatible.  net8.0-ios was computed.  net8.0-ios18.0 is compatible.  net8.0-maccatalyst was computed.  net8.0-maccatalyst18.0 is compatible.  net8.0-macos was computed.  net8.0-macos15.0 is compatible.  net8.0-tvos was computed.  net8.0-tvos18.0 is compatible.  net8.0-windows was computed.  net8.0-windows7.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.
  • net8.0-android34.0

    • No dependencies.
  • net8.0-browser1.0

    • No dependencies.
  • net8.0-ios18.0

    • No dependencies.
  • net8.0-maccatalyst18.0

    • No dependencies.
  • net8.0-macos15.0

    • No dependencies.
  • net8.0-tvos18.0

    • No dependencies.
  • net8.0-windows7.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on SimpleEncryption:

Package Downloads
SimpleFiles

The SimpleFiles is a powerful and easy-to-use solution for handling file and folder operations in .NET. With built-in encryption and flexibility, it simplifies file management while keeping your data secure. 🔒

SimpleSecureData

SimpleSecureData is a library designed to provide enhanced security for local applications by ensuring data remains encrypted in memory at all times. It uses platform-specific secure storage mechanisms

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 81 2/3/2025
1.0.3 105 1/24/2025
1.0.2 72 1/23/2025
1.0.1 67 1/23/2025
1.0.0 80 1/23/2025

- Updated Aes properties