MtdKey.Cipher 1.1.1

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

// Install MtdKey.Cipher as a Cake Tool
#tool nuget:?package=MtdKey.Cipher&version=1.1.1                

MTD Key Cipher

<a href="https://www.nuget.org/packages/MtdKey.Cipher">Nuget Package 1.0.2</a>

The library for exchanging encrypted messages between different applications.

<p>Allows messages to be exchanged kind of class objects.</p> Creates complex tokens that can be send over HTTP as hyperlinks and make APIs more flexible and secure.


  var tokenModel = new TestTokenModel()
  {
      UserName = "John Doe",
      Password = "password",
      Items = new() { "first", "second" }
  };

  var secretKey = AesCore.GenerateSecretKey();

  //It's an extension of the System.Security.Cryptography.Aes class
  using Aes aes = Aes.Create();
  var tokenEncrypted = aes.EncryptModel(tokenModel, secretKey);

  var tokenDecrypted = aes.DecryptModel<TestTokenModel>(tokenEncrypted, secretKey);

The special AesManager class can be used as a dependent injection in the Asp.Net Web App.

appsettings.json

  "AesOptions": {
    "SecretKey": "[Your secret key]",
    "KeySize": "256"
  },

Program.cs

  builder.Services.AddAesMangerService(options => {
        options.SecretKey = builder.Configuration.GetValue<string>("AesOptions:SecretKey");
        options.KeySize = builder.Configuration.GetValue<int>("AesOptions:KeySize");
  });

Index.cshtml.cs

  public class IndexModel : PageModel
  {
      private readonly IAesManager aesManager;

      public IndexModel(IAesManager aesManager)
      {
          this.aesManager = aesManager;
      }

      public IActionResult OnPost()
      {

        var encryptedData = aesManager.EncryptModel(tokenModel);
        var decryptedModel = aesManager.DecryptModel(encryptedData);
            
        ....
      }

  ....

  }

Examples of usage are located in the Tests, Api and Web folders.

Folder Description
src The library source code.
grpc An example gRPC server that encrypts and decrypts text messages can be used as a microservice.
api An example API application for creating complex secret tokens.
web Demo web application for creating unique tokens for each request of the same object.
tests Tests for this solution. (xUnit)

License

Copyright (c) – presented by Oleg Bruev.
MTDKey Cipher is free and open-source software licensed under the MIT License.

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
1.1.2 125 6/15/2024
1.1.1 116 6/15/2024
1.0.2 191 8/27/2023
1.0.1 178 8/27/2023
1.0.0 169 8/27/2023