SimpleEncryption 1.0.3

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

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.2 126 11 days ago
1.1.1 152 11 days ago
1.1.0 100 3 months ago
1.0.3 130 3 months ago
1.0.2 91 3 months ago
1.0.1 87 3 months ago
1.0.0 98 3 months ago

- Added ChaCha20 aad for decryption (bug fix)