Pandatech.Crypto 2.1.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package Pandatech.Crypto --version 2.1.4
                    
NuGet\Install-Package Pandatech.Crypto -Version 2.1.4
                    
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="Pandatech.Crypto" Version="2.1.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Pandatech.Crypto" Version="2.1.4" />
                    
Directory.Packages.props
<PackageReference Include="Pandatech.Crypto" />
                    
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 Pandatech.Crypto --version 2.1.4
                    
#r "nuget: Pandatech.Crypto, 2.1.4"
                    
#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.
#addin nuget:?package=Pandatech.Crypto&version=2.1.4
                    
Install as a Cake Addin
#tool nuget:?package=Pandatech.Crypto&version=2.1.4
                    
Install as a Cake Tool

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: Perform password hashing and verification with a focus on security and performance, leveraging the Argon2Id algorithm.
  • SHA-3 Hashing: Utilize 512-bit SHA-3 hashing for various applications.
  • 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. Configuring Dependency Injection

First, you'll need to configure Aes256 and Argon2Id in your application. To do so, add the following code to your Program.cs file:

using Pandatech.Crypto;


// For Aes256
builder.services.AddPandatechCryptoAes256(options =>
{
  options.Key = "YourAes256KeyHere"; // Make sure to use a secure key
});

// For Argon2Id overriding default configurations
  builder.services.AddPandatechCryptoArgon2Id(options =>
{
   options.SaltSize = 16;
   options.DegreeOfParallelism = 8;
   options.Iterations = 5;
   options.MemorySize = 128 * 1024;
});

2. AES256 Class

Immutable Configurations
  1. IV: A random IV is generated for each Encryption, enhancing security.
  2. PaddingMode: PKCS7
Encryption/Decryption methods with hashing
byte[] cipherText = aes256.Encrypt("your-plaintext");
string plainText = aes256.Decrypt(cipherText);
Encryption/Decryption methods without hashing
byte[] cipherText = aes256.Encrypt("your-plaintext", false);
string plainText = aes256.Decrypt(cipherText, false);
Encryption/Decryption methods with custom key (overriding options for one time)
string customKey = "your-custom-base64-encoded-key";
byte[] cipherText = aes256.Encrypt("your-plaintext", customKey);
string plainText = aes256.Decrypt(cipherText, customKey);

2. Argon2id Class

Default Configurations
  1. Salt: A random salt is generated for each password hash, enhancing security.
  2. DegreeOfParallelism: 8
  3. Iterations: 5
  4. 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 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.  net9.0 was computed.  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 (1)

Showing the top 1 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.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
5.0.2 171 6/1/2025
5.0.1 163 5/1/2025
5.0.0 143 4/11/2025
4.1.2 247 2/17/2025
4.1.1 277 11/28/2024
4.1.0 133 11/26/2024
4.0.0 161 11/21/2024
3.0.0 132 10/28/2024
2.6.1 175 10/19/2024
2.6.0 130 10/19/2024
2.5.1 148 10/18/2024
2.5.0 186 6/21/2024
2.4.1 159 6/14/2024
2.4.0 169 6/13/2024
2.3.2 433 5/9/2024
2.3.1 652 3/6/2024
2.3.0 158 3/6/2024
2.2.11 152 3/6/2024
2.2.10 152 3/1/2024
2.2.9 180 2/17/2024
2.2.8 143 2/17/2024
2.2.7 162 2/12/2024
2.2.6 175 1/23/2024
2.2.5 144 1/23/2024
2.2.4 155 1/19/2024
2.2.3 495 11/29/2023
2.2.2 139 11/29/2023
2.2.1 264 11/23/2023
2.2.0 178 11/21/2023
2.1.10 171 11/11/2023
2.1.9 154 11/9/2023
2.1.8 251 11/7/2023
2.1.7 224 11/6/2023
2.1.6 139 11/3/2023
2.1.5 165 11/2/2023
2.1.4 150 11/1/2023
2.1.3 158 11/1/2023
2.1.2 159 10/31/2023
2.1.1 158 10/31/2023
2.1.0 155 10/31/2023
2.0.0 347 10/30/2023
1.1.6 172 10/30/2023
1.1.5 161 10/27/2023
1.1.4 150 10/27/2023
1.1.3 177 10/27/2023
1.1.2 189 10/16/2023
1.1.1 188 10/14/2023
1.1.0 180 10/14/2023
1.0.0 178 10/13/2023

Added Random Id Generator for internal use