JadeEncryption 1.0.6

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

JadeEncryption: .NET 8 Encryption Library

.NET 8 .NET 9 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. Referenc the Package: Add a using statement in your package
    using JadeEncryption;
    
    

Demo for One way Encryption ideally for passwords

  1. Create an instance of OnewayEncryption class:

    OnewayEncryption oneWayEncryption = new OnewayEncryption();
    

    Or you can also create an instance by passing a number of iterations to the constructor. Higher the number of iterations more secure but will also require more system resource to process.

    OnewayEncryption oneWayEncryption = new OnewayEncryption(5);
    

    Alternatively you can also save your Key and IV in the appsettings.json file if you are working on a .net web application as below

     {
       "DataEncryption": {
         "Key": "YOUR KEY",
         "IV": "YOUR IV"
       }
     }
    
    
    
  2. Encrypt the data: The application will include the salt so no need to separately store the salt.

    string encrypedString = oneWayEncryption.HashData("This string is not encrypted");
    
    
  3. Verify the hash against a probably match. Ideally passwords Here you pass in the original hashed string as the first argument and the second parameter is the string that should match.

    if(oneWayEncryption.VerifyHash(encrypedString, "Not encryped string")) 
    {
        Console.WriteLine("Hash is verified which is the expected result");
    }
    
    
    

Demo for Two way Encryption ideally for storing data encryped at rest and then decrypting it to use in your application.

So this will require a 16 or 24 or 32 bit key and a 16 bit IV. You can use the Key Gen class to generate these. Note that everytime the Key Gen may generate new keys so generate once and save in your application. And in future encrypt decrypt requests use the same key. You can also bring in your own keys but make sure they follow the AES Encryption rules.

!Important: Don't directly pass the generate key function in the TwoWayEncryption constructor. If done, the encryptions will not match as the encryption and decription keys need to be same.

  1. Generate Keys or Bring your own AES Keys
    string key = KeyGen.GenerateAesKey(KeySize.KeySize_256);
    string iv = KeyGen.GenerateIv();
    
    
    
  2. Instanciate the TwoWayEncryption class:
    TwoWayEncryption twoWayEncrypt = new TwoWayEncryption(key, iv);
    
    
  3. Encrypt the data by calling the Encrypt() Method:
    string twoWayEncryptedString = twoWayEncrypt.Encrypt("HELLO WORLD");
    
    
  4. Decrypt the data
    string twoWayDecryptedString = twoWayEncrypt.Decrypt([YOUR TWO WAY ENCRYPTED STRING]]);
    
    
    
    

Important Note

Both encryptions use different methods. The hashing method's encription cannot be passed to the two way decryption to be decrypted.

Conclusion

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 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. 
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.6 74 7/18/2025
1.0.5 70 7/18/2025
1.0.4 153 4/23/2025
1.0.2 150 4/23/2025
1.0.1 128 9/29/2024
1.0.0 112 9/29/2024