JadeEncryption 1.0.6
dotnet add package JadeEncryption --version 1.0.6
NuGet\Install-Package JadeEncryption -Version 1.0.6
<PackageReference Include="JadeEncryption" Version="1.0.6" />
<PackageVersion Include="JadeEncryption" Version="1.0.6" />
<PackageReference Include="JadeEncryption" />
paket add JadeEncryption --version 1.0.6
#r "nuget: JadeEncryption, 1.0.6"
#:package JadeEncryption@1.0.6
#addin nuget:?package=JadeEncryption&version=1.0.6
#tool nuget:?package=JadeEncryption&version=1.0.6
JadeEncryption: .NET 8 Encryption Library
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
- Install the Package:
dotnet add package JadeEncryption
- Referenc the Package:
Add a using statement in your package
using JadeEncryption;
Demo for One way Encryption ideally for passwords
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" } }
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");
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.
- Generate Keys or Bring your own AES Keys
string key = KeyGen.GenerateAesKey(KeySize.KeySize_256); string iv = KeyGen.GenerateIv();
- Instanciate the TwoWayEncryption class:
TwoWayEncryption twoWayEncrypt = new TwoWayEncryption(key, iv);
- Encrypt the data by calling the Encrypt() Method:
string twoWayEncryptedString = twoWayEncrypt.Encrypt("HELLO WORLD");
- 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 | Versions 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. |
-
net8.0
- Microsoft.Extensions.Configuration (>= 9.0.7)
-
net9.0
- Microsoft.Extensions.Configuration (>= 9.0.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.