Pandatech.Crypto
2.0.0
See the version list below for details.
dotnet add package Pandatech.Crypto --version 2.0.0
NuGet\Install-Package Pandatech.Crypto -Version 2.0.0
<PackageReference Include="Pandatech.Crypto" Version="2.0.0" />
paket add Pandatech.Crypto --version 2.0.0
#r "nuget: Pandatech.Crypto, 2.0.0"
// Install Pandatech.Crypto as a Cake Addin #addin nuget:?package=Pandatech.Crypto&version=2.0.0 // Install Pandatech.Crypto as a Cake Tool #tool nuget:?package=Pandatech.Crypto&version=2.0.0
PandaTech.Crypto
Introduction
Pandatech.Crypto is a powerful cryptographic utility library backed by 99% test coverage through unit tests. The library offers an array of static methods for secure data operations, including AES256 encryption and decryption, Argon2Id password hashing and verification, as well as utilities for generating cryptographic random bytes and passwords.
Designed to work efficiently in containerized environments, the library performs effectively even with limited resources—hash generation takes under 500ms on a container with 1 vCore and 1GB of RAM.
Features
- AES 256-bit Encryption/Decryption: Encrypt your data and get the IV and encrypted bytes in one array. Decrypt it back to its original form, seamlessly handling the IV. Note that you have option to encrypt with hash and decrypt ignoring hash. (for cases where you want to apply filtering on the encrypted data or check uniqueness of the encrypted data)
- Argon2Id Hashing: Hash and verify passwords securely with an immutable configuration that's optimized for performance.
- SHA-3 Hashing: Generate and verify SHA-3 hashes with 512-bit output.
- Random Number/Password Generation: Generate cryptographic random bytes, AES256 keys, or strong passwords with specific character sets.
- Performance Optimized: Tested to run efficiently in resource-constrained environments.
- High Test Coverage: Confidence backed by 99% unit test coverage.
Installation
To use PandaTech.Crypto
in your project, install the NuGet package using the following command in the Package Manager
Console:
Install-Package PandaTech.Crypto
or, search for "PandaTech.Crypto" in the NuGet Package Manager and install it from
there.
How to Use
1. AES256 Class
Configurations
- IV: A random IV is generated for each Encryption, enhancing security.
- PaddingMode: PKCS7
Methods
- Encrypt(string plainText): Encrypts a plain text using a default environment variable key.
- Encrypt(string plainText, string key): Encrypts a plain text using a given key.
- Decrypt(byte[] cipherText): Decrypts to plain text using a default environment variable key.
- Decrypt(byte[] cipherText, string key): Decrypts to plain text using a given key.
- EncryptWithHash(string plainText): Encrypts and appends SHA-3 hash. (for cases where you want to apply filtering on the encrypted data)
- DecryptIgnoringHash(byte[] cipherTextWithHash): Decrypts while ignoring SHA-3 hash. (for cases where you want to apply filtering on the encrypted data)
- EncryptWithHash(string plainText, string key): Encrypts using a given key and appends SHA-3 hash. (for cases where you want to apply filtering on the encrypted data)
- DecryptIgnoringHash(byte[] cipherTextWithHash, string key): Decrypts using a given key while ignoring SHA-3 hash. (for cases where you want to apply filtering on the encrypted data) Encryption and decryption with environment variable key
// Example for basic encryption and decryption
Environment.SetEnvironmentVariable("AES_KEY", Random.GenerateAes256KeyString());
var encryptedData = Aes256.Encrypt("PlainText");
var decryptedData = Aes256.Decrypt(encryptedData);
// Example for encryption with hash
var encryptedWithHash = Aes256.EncryptWithHash("PlainText");
// Example for decryption ignoring hash
var decryptedIgnoringHash = Aes256.DecryptIgnoringHash(encryptedWithHash);
2. Argon2id Class
Configurations
- Salt: A random salt is generated for each password hash, enhancing security.
- DegreeOfParallelism: 8
- Iterations: 5
- MemorySize: 128 MB
Hash password and verify hash
// Example usage for hashing
var hashedPassword = Argon2Id.HashPassword("yourPassword");
// Example usage for verifying a hash
var isPasswordValid = Argon2Id.VerifyHash("yourPassword", hashedPassword);
3. Random Class
var randomBytes = Random.GenerateBytes(16);
var aesKey = Random.GenerateAes256KeyString();
4. RandomPassword Class
var includeUppercase = true;
var includeLowercase = true;
var includeDigits = true;
var includeSpecialChars = true;
string password = RandomPassword.Generate(16, includeUppercase, includeLowercase, includeDigits, includeSpecialChars);
5. Sha3 Class
// Example usage for generating hash
var sha3Hash = Sha3.Hash("yourPlainText");
// Example usage for verifying a hash
var isHashValid = Sha3.VerifyHash("yourPlainText", sha3Hash);
License
PandaTech.Crypto is licensed under the MIT License.
Your Security, Our Priority.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
-
net7.0
- BouncyCastle.NetCore (>= 2.2.1)
- Konscious.Security.Cryptography.Argon2 (>= 1.3.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Pandatech.Crypto:
Package | Downloads |
---|---|
Pandatech.SharedKernel
Pandatech.SharedKernel provides centralized configurations, utilities, and extensions for ASP.NET Core projects. For more information refere to readme.md document. |
|
Pandatech.SharedKernel.Postgres
Pandatech.SharedKernel.Postgres simplifies PostgreSQL integration in ASP.NET Core applications by providing utilities for Entity Framework Core setup, health checks, and other enhancements. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
4.1.1 | 95 | 11/28/2024 |
4.1.0 | 84 | 11/26/2024 |
4.0.0 | 112 | 11/21/2024 |
3.0.0 | 84 | 10/28/2024 |
2.6.1 | 106 | 10/19/2024 |
2.6.0 | 95 | 10/19/2024 |
2.5.1 | 110 | 10/18/2024 |
2.5.0 | 149 | 6/21/2024 |
2.4.1 | 112 | 6/14/2024 |
2.4.0 | 123 | 6/13/2024 |
2.3.2 | 269 | 5/9/2024 |
2.3.1 | 604 | 3/6/2024 |
2.3.0 | 127 | 3/6/2024 |
2.2.11 | 117 | 3/6/2024 |
2.2.10 | 121 | 3/1/2024 |
2.2.9 | 145 | 2/17/2024 |
2.2.8 | 104 | 2/17/2024 |
2.2.7 | 133 | 2/12/2024 |
2.2.6 | 143 | 1/23/2024 |
2.2.5 | 113 | 1/23/2024 |
2.2.4 | 124 | 1/19/2024 |
2.2.3 | 479 | 11/29/2023 |
2.2.2 | 122 | 11/29/2023 |
2.2.1 | 230 | 11/23/2023 |
2.2.0 | 155 | 11/21/2023 |
2.1.10 | 147 | 11/11/2023 |
2.1.9 | 135 | 11/9/2023 |
2.1.8 | 229 | 11/7/2023 |
2.1.7 | 207 | 11/6/2023 |
2.1.6 | 123 | 11/3/2023 |
2.1.5 | 145 | 11/2/2023 |
2.1.4 | 129 | 11/1/2023 |
2.1.3 | 137 | 11/1/2023 |
2.1.2 | 136 | 10/31/2023 |
2.1.1 | 137 | 10/31/2023 |
2.1.0 | 136 | 10/31/2023 |
2.0.0 | 328 | 10/30/2023 |
1.1.6 | 150 | 10/30/2023 |
1.1.5 | 143 | 10/27/2023 |
1.1.4 | 127 | 10/27/2023 |
1.1.3 | 153 | 10/27/2023 |
1.1.2 | 166 | 10/16/2023 |
1.1.1 | 165 | 10/14/2023 |
1.1.0 | 156 | 10/14/2023 |
1.0.0 | 153 | 10/13/2023 |
AES256 encrypted byte array sequence changed