Skip to content

NTDLS.Permafrost Usage

A symmetric encryption library for C# with cipher and stream modes that chain with compression.

Published Jul 25, 2026

NTDLS.Permafrost

What it is. A symmetric encryption library for C#, derived from NASCCL (the NetworkDLS Algorithmic Symmetric Cipher Cryptography Library). It offers two shapes: PermafrostCipher for encrypting byte arrays in memory, and PermafrostStream for streaming files or network data - which can be chained directly with a GZipStream so you get encryption plus compression in one pipeline.

When to reach for it. You want to obfuscate or protect data at rest (files, config blobs) with a simple password-based API and no ceremony around key derivation. Skip it if you need an audited, standards-based scheme such as AES-GCM; Permafrost is a custom algorithm, so treat it as strong obfuscation against casual inspection rather than a substitute for vetted cryptography.

Getting started

The in-memory form is three lines. Note that calling Cipher on already-encrypted bytes decrypts them:

using var permafrost = new PermafrostCipher("ThisIsTheP@$$w0Rd!", PermafrostMode.AutoReset);

var cipherBytes = permafrost.Cipher(
    Encoding.UTF8.GetBytes("This is some text I would like to keep safe."));

var decipherBytes = permafrost.Cipher(cipherBytes);
string decipheredText = Encoding.UTF8.GetString(decipherBytes);

For files, wrap a stream and chain a GZipStream on top. Encryption writes compressed-then-encrypted bytes; decryption reverses the order:

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);
    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];

    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);
    }
}

NuGet: NTDLS.Permafrost

An unhandled error has occurred. Reload 🗙