Vinay.Security.Encryption 1.0.3

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

EncryptionClassLib

EncryptionClassLib is a C# library providing easy-to-use, customizable encryption and decryption methods. It supports both AES and RijndaelManaged algorithms with 128-bit and 256-bit key sizes. The library is designed for seamless integration into .NET 6 projects, enabling secure data handling across your applications.

Features

  • AES Encryption/Decryption
  • 128-bit and 256-bit key support
  • Key generation (random or AES-based)
  • Asynchronous result wrappers
  • RijndaelManaged Encryption/Decryption
  • 128-bit and 256-bit key support
  • Simple string-based API
  • Custom Key Management
  • Set and use your own security key
  • Result Data Model
  • Consistent input/output encapsulation for easy integration

Getting Started

Prerequisites

  • .NET 6 or later
  • C# 10.0 or later

Installation

Add the project or compiled DLL to your solution.
Add a reference to EncryptionClassLib in your project.

Usage

1. Set the Security Key

EncryptionAsync.GetKey("YourSecretKey123!");

2. Encrypt/Decrypt with AES (128-bit)

// Encrypt
var result = await EncryptionAsync.EncryptionResult128("SensitiveData", null);
Console.WriteLine(result.Output);

// Decrypt
var decrypted = await EncryptionAsync.DcryptionResult128(result.Output, null);
Console.WriteLine(decrypted.Output);

3. Encrypt/Decrypt with AES (256-bit)

var result = await EncryptionAsync.EncryptionResult256("SensitiveData", null);
var decrypted = await EncryptionAsync.DcryptionResult256(result.Output, null);

4. Encrypt/Decrypt with RijndaelManaged (128/256-bit)

string encrypted128 = EncryptionAsync.Encrypt128("SensitiveData", "YourKey");
string decrypted128 = EncryptionAsync.Decrypt128(encrypted128, "YourKey");

string encrypted256 = EncryptionAsync.Encrypt256("SensitiveData", "YourKey");
string decrypted256 = EncryptionAsync.Decrypt256(encrypted256, "YourKey");

5. Custom Key Management

string randomKey = EncryptionAsync.GenerateRandomString(16); // 16 or 32 chars
string aesKey = EncryptionAsync.GenerateAESKey(128); // 128 or 256

API Reference

  • EncryptionAsync.GetKey(string securityKey)
  • EncryptionAsync.GenerateRandomString(int length)
  • EncryptionAsync.GenerateAESKey(int keySize)
  • EncryptionAsync.EncryptionResult128(string inputData, string key)
  • EncryptionAsync.DcryptionResult128(string encryptionData, string key)
  • EncryptionAsync.EncryptionResult256(string inputData, string key)
  • EncryptionAsync.DcryptionResult256(string encryptionData, string key)
  • EncryptionAsync.Encrypt128(string plainText, string key)
  • EncryptionAsync.Decrypt128(string encryptedText, string key)
  • EncryptionAsync.Encrypt256(string plainText, string key)
  • EncryptionAsync.Decrypt256(string encryptedText, string key)

ResultData Model

public class ResultData
{
    public string Input { get; set; }
    public string Output { get; set; }
    public string Key { get; set; }
}

Security Notes

  • Always use strong, unique keys for encryption.
  • Never hard-code sensitive keys in source code.
  • For production, consider secure key storage (e.g., Azure Key Vault, AWS KMS).

License

This project is licensed for personal and commercial use.
See LICENSE for details.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  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.
  • net6.0

    • No dependencies.

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.3 286 6/10/2025
1.0.2 286 6/10/2025
1.0.1 284 6/10/2025
1.0.0 504 6/10/2025 1.0.0 is deprecated because it is no longer maintained and has critical bugs.