String.Encoder.Decoder 8.0.2

dotnet add package String.Encoder.Decoder --version 8.0.2                
NuGet\Install-Package String.Encoder.Decoder -Version 8.0.2                
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="String.Encoder.Decoder" Version="8.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add String.Encoder.Decoder --version 8.0.2                
#r "nuget: String.Encoder.Decoder, 8.0.2"                
#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.
// Install String.Encoder.Decoder as a Cake Addin
#addin nuget:?package=String.Encoder.Decoder&version=8.0.2

// Install String.Encoder.Decoder as a Cake Tool
#tool nuget:?package=String.Encoder.Decoder&version=8.0.2                

EncodeDecode Class

The EncodeDecode class provides encryption and decryption functionality using AES (Advanced Encryption Standard) with a customizable initialization vector and passphrase. It is designed to securely encode and decode data using a salted encryption approach.

Features

  • AES encryption: Securely encrypts plaintext data using the AES algorithm in CBC mode.
  • AES decryption: Decodes AES-encrypted ciphertext back into plaintext.
  • Salted encryption: Includes salt values for added security during encryption.
  • Customizable parameters: You can specify the passphrase, salt, and initialization vector (IV) for encryption.

Requirements

  • .NET 5 or higher
  • A minimum passphrase length of 8 characters
  • A minimum salt length of 8 characters
  • An initialization vector (IV) that must be exactly 16 characters

How to Use

1. Using Dependency Injection

In your app settings add the configuration settings:

 "EncodeDecodeConfiguration": {
    "PasswordIterations": 2,
    "Salt": "ThisIsYourSalt",
    "InitVector": "@1B2c3D4e5F6g7H8",
    "Passphrase": "DoNotUseForPasswords"
  }

Register the service in your program.cs file


    services.Configure<EncodeDecodeConfiguration>(context.Configuration.GetSection(EncodeDecodeConfiguration.Name));
    services.AddScoped<IEncodeDecode, EncodeDecode>();

Inject the service where you need it:

     private readonly IEncodeDecode _encryptor;
      public YourClassConstructor(IEncodeDecode encrypt)
        {
            _encryptor = encrypt;
        }
        public void test()
        {
            Console.WriteLine("Enter Text");
            var text = Console.ReadLine();
            var encrypted = _encryptor.Encrypt(text);
            var decrypted =_encryptor.Decrypt(encrypted);
            Console.WriteLine(encrypted);
            Console.WriteLine("****************");
            Console.WriteLine(decrypted);
        }

2. Without Dependency Injection You May Initialize the EncodeDecode

You can initialize the EncodeDecode class with the following parameters:

string passPhrase = "YourPassphrase"; // At least 8 characters
string salt = "YourSaltValue";        // At least 8 characters
string initVector = "@1B2c3D4e5F6g7H8"; // Must be exactly 16 characters

EncodeDecode encryptor = new EncodeDecode(passPhrase, salt, initVector);

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
8.0.2 82 10/17/2024
3.0.0 633 1/17/2021
2.0.0 852 10/4/2020
1.2.1 482 3/17/2020
1.2.0 443 3/17/2020
1.0.0 451 3/16/2020

Upgraded to Net 8
Added Dependency Injection