JadeEncryption 1.0.7

dotnet add package JadeEncryption --version 1.0.7
                    
NuGet\Install-Package JadeEncryption -Version 1.0.7
                    
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="JadeEncryption" Version="1.0.7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="JadeEncryption" Version="1.0.7" />
                    
Directory.Packages.props
<PackageReference Include="JadeEncryption" />
                    
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 JadeEncryption --version 1.0.7
                    
#r "nuget: JadeEncryption, 1.0.7"
                    
#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 JadeEncryption@1.0.7
                    
#: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=JadeEncryption&version=1.0.7
                    
Install as a Cake Addin
#tool nuget:?package=JadeEncryption&version=1.0.7
                    
Install as a Cake Tool

JadeEncryption: .NET 8 Encryption Library

.NET 8 .NET 9 .NET 10 Nuget License: MIT

JadeEncryption provides easy-to-use methods for both one-way (hashing) and two-way (reversible) encryption within your .NET 8 projects.

Important: Migrating from Jaded Encryption

Those previously using Jaded Encryption can migrate to this by changing the below reference

using JadeEncryption;

To

using JadeEncryption;

Features

  • One-Way Encryption (Hashing):
    • Securely hash sensitive data (e.g., passwords) for storage.
    • Verification to ensure data integrity.
  • Two-Way Encryption:
    • Encrypt and decrypt confidential information.
    • Supports various key sizes (128, 192, 256 bits).
    • Utilizes AES (Advanced Encryption Standard) for robustness.

Getting Started

  1. Install the Package:
    dotnet add package JadeEncryption
    
    
  2. Reference the Package: Add a using statement in your code:
    using JadeEncryption;
    
    
    

Demo: One-Way Encryption (Hashing)

  1. Create an instance of OnewayEncryption:

    OnewayEncryption oneWayEncryption = new OnewayEncryption();
    

    Or specify a custom iteration count (recommended: 10,000+ for new projects):

    OnewayEncryption oneWayEncryption = new OnewayEncryption(10000);
    

    Security Note: The default iteration count is 10 for backward compatibility. For new projects, use a higher value (e.g., 10,000 or more) for better security.

  2. Hash the data: The salt is included in the output, so you do not need to store it separately.

    string hashedString = oneWayEncryption.HashData("This string is not encrypted");
    
  3. Verify the hash: Pass the original hash and the string to check:

    if(oneWayEncryption.VerifyHash(hashedString, "This string is not encrypted"))
    {
        Console.WriteLine("Hash is verified which is the expected result");
    }
    

Demo: Two-Way Encryption (AES)

You need a 16, 24, or 32 byte key and a 16 byte IV. Use the KeyGen class to generate these. Generate once and store securely (e.g., environment variables, Azure Key Vault). Do not generate a new key/IV for every operation.

Important: Do NOT call the key/IV generator every time you encrypt or decrypt. The key and IV must remain the same for decryption to work.

  1. Generate or provide AES keys:

    string key = KeyGen.GenerateAesKey(KeySize.KeySize_256);
    string iv = KeyGen.GenerateIv();
    
  2. Instantiate the TwoWayEncryption class:

    TwoWayEncryption twoWayEncrypt = new TwoWayEncryption(key, iv);
    
  3. Encrypt data:

    string twoWayEncryptedString = twoWayEncrypt.Encrypt("HELLO WORLD");
    
  4. Decrypt data:

    string twoWayDecryptedString = twoWayEncrypt.Decrypt(twoWayEncryptedString);
    

Security Note: Never hardcode keys/IVs in your source code. Store them securely using environment variables or a secrets manager.

Security Best Practices

  • Use a high iteration count (10,000+) for PBKDF2 hashing.
  • Store encryption keys and IVs securely (never in source code).
  • Rotate keys periodically and follow your organization's security policies.
  • Do not use the same key/IV pair for multiple applications.
  • Always validate user input and handle exceptions securely.

Important Note

One-way and two-way encryption are not interchangeable. You cannot decrypt a hash produced by the one-way method.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Happy Coding!

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 is compatible.  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 is compatible.  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.

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.7 197 12/26/2025
1.0.6 150 7/18/2025
1.0.5 136 7/18/2025
1.0.4 199 4/23/2025
1.0.2 198 4/23/2025
1.0.1 158 9/29/2024
1.0.0 150 9/29/2024