JadeEncryption 1.0.7
dotnet add package JadeEncryption --version 1.0.7
NuGet\Install-Package JadeEncryption -Version 1.0.7
<PackageReference Include="JadeEncryption" Version="1.0.7" />
<PackageVersion Include="JadeEncryption" Version="1.0.7" />
<PackageReference Include="JadeEncryption" />
paket add JadeEncryption --version 1.0.7
#r "nuget: JadeEncryption, 1.0.7"
#:package JadeEncryption@1.0.7
#addin nuget:?package=JadeEncryption&version=1.0.7
#tool nuget:?package=JadeEncryption&version=1.0.7
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 - Reference the Package:
Add a using statement in your code:
using JadeEncryption;
Demo: One-Way Encryption (Hashing)
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.
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");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.
Generate or provide AES keys:
string key = KeyGen.GenerateAesKey(KeySize.KeySize_256); string iv = KeyGen.GenerateIv();Instantiate the TwoWayEncryption class:
TwoWayEncryption twoWayEncrypt = new TwoWayEncryption(key, iv);Encrypt data:
string twoWayEncryptedString = twoWayEncrypt.Encrypt("HELLO WORLD");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 | 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 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. |
-
net10.0
- Microsoft.Extensions.Configuration (>= 10.0.1)
-
net8.0
- Microsoft.Extensions.Configuration (>= 10.0.1)
-
net9.0
- Microsoft.Extensions.Configuration (>= 10.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.