NTDLS.Permafrost

Status: Stable
Released: 2025-03-23
License: MIT License

This is open source under the MIT License. You can obtain the source code from GitHub or browse the releases for source code associated with specific versions. If you make any changes which you feel improves this application, please feel free to submit a pull - request.

NTDLS.Permafrost

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

Permafrost encryption library, derived from NASCCL. The NetworkDLS Algorithmic Symmetric Cipher Cryptography Library.

Simple string encryption example:

using var permafrost = new PermafrostCipher("ThisIsTheP@$$w0Rd!", PermafrostMode.AutoReset);
var cipherBytes = permafrost.Cipher("This is some text that I would like to keep safe if that is ok with you? Oh, it is? Good!");
var decipherBytes = permafrost.Cipher(cipherBytes);
string decipheredText = Encoding.UTF8.GetString(decipherBytes);

Streaming example with chaining.

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

Visulation of 1MB NULL values.