Krypt.Core
1.0.0
dotnet add package Krypt.Core --version 1.0.0
NuGet\Install-Package Krypt.Core -Version 1.0.0
<PackageReference Include="Krypt.Core" Version="1.0.0" />
<PackageVersion Include="Krypt.Core" Version="1.0.0" />
<PackageReference Include="Krypt.Core" />
paket add Krypt.Core --version 1.0.0
#r "nuget: Krypt.Core, 1.0.0"
#:package Krypt.Core@1.0.0
#addin nuget:?package=Krypt.Core&version=1.0.0
#tool nuget:?package=Krypt.Core&version=1.0.0
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.
Features
- AES-256-CBC encryption with automatic IV generation
- Key derivation from any passphrase via SHA-256
- Multiple overloads:
string,byte[], andStream(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");
Async stream (recommended for large files / web apps)
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
| Product | Versions 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. |
-
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.
