Krypt.Core 1.0.0

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

Krypt

Krypt is a .NET library for encryption and decryption of data. It provides a simple and secure way to protect sensitive information in your applications.

NuGet License: MIT .NET


Features

  • AES-256-CBC encryption with automatic IV generation
  • Key derivation from any passphrase via SHA-256
  • Multiple overloads: string, byte[], and Stream (sync + async)
  • IV prepended to cipher output — no extra plumbing needed
  • Zero dependencies beyond the .NET BCL

Installation

dotnet add package Krypt.Core

Quick Start

Encrypt & decrypt a string

using Krypt;

string secretKey = "secretkey123";
string toEncrypt = "Hello World!";

string encrypted = Krypt.Encryption.KryptAes.Encrypt(toEncrypt, secretKey);
Console.WriteLine($"Encrypted: {encrypted}");

string decrypted = Krypt.Encryption.KryptAes.Decrypt(encrypted, secretKey);
Console.WriteLine($"Decrypted: {decrypted}");
// Output:
// Encrypted: <base64 cipher>
// Decrypted: Hello World!

Encrypt & decrypt raw bytes

using Krypt.Encryption;

byte[] data   = File.ReadAllBytes("document.pdf");
byte[] cipher = KryptAes.Encrypt(data, "my-secret-passphrase");
byte[] plain  = KryptAes.Decrypt(cipher, "my-secret-passphrase");

Encrypt & decrypt a file (stream)

using Krypt.Encryption;

using FileStream input  = File.OpenRead("video.mp4");
using FileStream output = File.Create("video.mp4.enc");

KryptAes.Encrypt(input, output, "my-secret-passphrase");
using FileStream cipher   = File.OpenRead("video.mp4.enc");
using FileStream restored = File.Create("video_restored.mp4");

KryptAes.Decrypt(cipher, restored, "my-secret-passphrase");
await KryptAes.EncryptAsync(inputStream, outputStream, "my-secret-passphrase", cancellationToken);
await KryptAes.DecryptAsync(cipherStream, outputStream, "my-secret-passphrase", cancellationToken);

API Reference

Method Description
Encrypt(string, string) → string Encrypts a UTF-8 string; returns Base-64 cipher
Decrypt(string, string) → string Decrypts a Base-64 cipher; returns UTF-8 string
Encrypt(byte[], string) → byte[] Encrypts raw bytes
Decrypt(byte[], string) → byte[] Decrypts raw bytes
Encrypt(Stream, Stream, string) Stream encryption (sync)
Decrypt(Stream, Stream, string) Stream decryption (sync)
EncryptAsync(Stream, Stream, string, CancellationToken) Stream encryption (async)
DecryptAsync(Stream, Stream, string, CancellationToken) Stream decryption (async)

Technical Details

Property Value
Algorithm AES
Key size 256 bits
Mode CBC
Padding PKCS7
IV size 16 bytes (prepended to cipher output)
Key derivation SHA-256 over the passphrase (UTF-8)

The IV is randomly generated on every Encrypt call and prepended to the output. Decrypt strips it automatically — you never need to manage the IV yourself.

Note: Key derivation uses a single SHA-256 pass for performance and portability. If you need stronger key stretching for user-facing passwords, consider pre-deriving your key with PBKDF2 or Argon2 before passing it to Krypt.


Requirements

  • .NET 8 or later

License

MIT

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.  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.
  • net8.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.