NTDLS.Permafrost 2.2.2

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

NTDLS.Permafrost

Permafrost is a lightweight symmetric encryption library for .NET, derived from NASCCL (the NetworkDLS Algorithmic Symmetric Cipher Cryptography Library). It exposes two simple entry points: PermafrostCipher for encrypting and decrypting in-memory byte arrays and strings, and PermafrostStream, a standard System.IO.Stream that transparently encrypts or decrypts everything you read through or write to it. Both support string or byte-array keys, an optional seed, and two operating modes: AutoReset (each call starts fresh, so encryption and decryption order does not matter) and Continuous (stateful, where each call depends on the one before it — suitable for streaming data).

📦 Be sure to check out the NuGet package: https://www.nuget.org/packages/NTDLS.Permafrost

When to use this package

  • You want a fast, dependency-free way to obfuscate or protect small pieces of data in memory (strings, buffers, config values) without pulling in a heavyweight cryptography stack.
  • You need to encrypt or decrypt a file, network stream, or any other Stream on the fly by wrapping it in a PermafrostStream. Because it is a plain Stream, it composes with anything else in the pipeline — for example, chain it with GZipStream to both compress and encrypt files.
  • You prefer a simple, key-based API (new PermafrostCipher("myKey")) over building and managing SymmetricAlgorithm objects yourself.
  • You are working within the NASCCL ecosystem and want its cipher available as a maintained, multi-targeted NuGet package (net8.0 / net9.0 / net10.0).

Usage examples

Encrypt and decrypt a string

using NTDLS.Permafrost;

// AutoReset mode: the key state resets after every call,
// so you can encrypt and decrypt in any order.
using var permafrost = new PermafrostCipher("ThisIsTheP@$$w0Rd!", PermafrostMode.AutoReset);

// Encrypt a UTF-8 string into ciphertext bytes.
byte[] cipherBytes = permafrost.Cipher("This is some text that I would like to keep safe.");

// Decrypt the ciphertext back into a readable string.
string decipheredText = permafrost.DecryptString(cipherBytes);

Encrypt and decrypt byte arrays in place

using NTDLS.Permafrost;

// Continuous mode: each call depends on the previous one,
// which is what you want for sequential/streaming data.
using var permafrost = new PermafrostCipher("ThisIsTheP@$$w0Rd!"); // defaults to Continuous

byte[] data = [ 0x01, 0x02, 0x03, 0x04, 0x05 ];

// XOR the buffer with the rolling key stream, mutating it in place.
permafrost.CipherInPlace(data);   // encrypt
permafrost.CipherInPlace(data);   // decrypt (same operation applied again)

Stream a file through encryption (with compression chaining)

using System.IO.Compression;
using NTDLS.Permafrost;

public static void EncryptAndCompressFile(string inputPath, string outputPath)
{
    byte[] buffer = new byte[8192];

    using var input = File.OpenRead(inputPath);
    using var output = File.Create(outputPath);

    // Wrap the output stream so everything written to it is encrypted,
    // then wrap that with GZipStream so the data is also compressed.
    using var permafrost = new PermafrostStream(output, "ThisIsTheP@$$w0Rd!");
    using var gzip = new GZipStream(permafrost, CompressionLevel.SmallestSize);

    int bytesRead;
    while ((bytesRead = input.Read(buffer, 0, buffer.Length)) > 0)
        gzip.Write(buffer, 0, bytesRead);
}

public static void DecryptAndDecompressFile(string inputPath, string outputPath)
{
    byte[] buffer = new byte[8192];

    // On the way back, decompress first and then decrypt,
    // mirroring the order used when writing.
    using var input = File.OpenRead(inputPath);
    using var permafrost = new PermafrostStream(input, "ThisIsTheP@$$w0Rd!");
    using var gzip = new GZipStream(permafrost, CompressionMode.Decompress);
    using var output = File.Create(outputPath);

    int bytesRead;
    while ((bytesRead = gzip.Read(buffer, 0, buffer.Length)) > 0)
        output.Write(buffer, 0, bytesRead);
}

Visulation of 1MB NULL values.

TestOutput txt

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 is compatible.  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 is compatible.  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.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.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
2.2.2 84 11/30/2026
2.2.1 95 11/30/2026
2.2.0 196 6/3/2026
2.1.2 359 11/14/2025
2.1.1 261 5/2/2025
2.1.0 413 3/23/2025
2.0.0 399 3/23/2025
1.0.0 289 3/23/2025

Simplify constructor API across PermafrostCipher and Stream