CodeBrix.Compression.MitLicenseForever
1.0.248.1109
dotnet add package CodeBrix.Compression.MitLicenseForever --version 1.0.248.1109
NuGet\Install-Package CodeBrix.Compression.MitLicenseForever -Version 1.0.248.1109
<PackageReference Include="CodeBrix.Compression.MitLicenseForever" Version="1.0.248.1109" />
<PackageVersion Include="CodeBrix.Compression.MitLicenseForever" Version="1.0.248.1109" />
<PackageReference Include="CodeBrix.Compression.MitLicenseForever" />
paket add CodeBrix.Compression.MitLicenseForever --version 1.0.248.1109
#r "nuget: CodeBrix.Compression.MitLicenseForever, 1.0.248.1109"
#:package CodeBrix.Compression.MitLicenseForever@1.0.248.1109
#addin nuget:?package=CodeBrix.Compression.MitLicenseForever&version=1.0.248.1109
#tool nuget:?package=CodeBrix.Compression.MitLicenseForever&version=1.0.248.1109
CodeBrix.Compression
Create, read and extract Zip, GZip, Tar and BZip2 archives using .NET; plus decompress PKWARE DCL "imploded" and LZW ".Z" data.
CodeBrix.Compression is a .NET library for working with compressed archives in multiple formats including Zip, GZip, Tar and BZip2 - and can decompress raw data in the PKWARE Data Compression Library (DCL) "imploded" format used by many MS-DOS-era installers, as well as the LZW/LZC ".Z" format written by the classic Unix compress utility. It supports encryption (AES-128 and AES-256), Zip64, and streaming operations for both creation and extraction of archives.
CodeBrix.Compression has no dependencies other than .NET, and is provided as a .NET 10 library and associated CodeBrix.Compression.MitLicenseForever NuGet package.
CodeBrix.Compression supports applications and assemblies that target Microsoft .NET version 10.0 and later. Microsoft .NET version 10.0 is a Long-Term Supported (LTS) version of .NET, and was released on Nov 11, 2025; and will be actively supported by Microsoft until Nov 14, 2028. Please update your C#/.NET code and projects to the latest LTS version of Microsoft .NET.
Installation
dotnet add package CodeBrix.Compression.MitLicenseForever
Note that the NuGet package ID and the namespace are different - there is no package named plain CodeBrix.Compression:
- NuGet package ID:
CodeBrix.Compression.MitLicenseForever - Assembly and root namespace:
CodeBrix.Compression- i.e.using CodeBrix.Compression.Zip;
The package has no NuGet dependencies and no native libraries; it depends only on the .NET base class library. XML documentation (IntelliSense) ships alongside the assembly.
CodeBrix.Compression supports:
- Zip archives (create, read, update, extract)
- GZip compression and decompression
- Tar archives (create, read, extract)
- BZip2 compression and decompression
- DCL (PKWARE Data Compression Library "implode" format) decompression
- LZW (.Z) decompression
- AES-128 and AES-256 encryption for Zip archives
- Zip64 extensions for large files
- Streaming (non-seekable) input and output
- In-memory archive operations
- Checksums (CRC-32, Adler32, BZip2 CRC)
- Many more...
Only Zip archives can be updated in place; GZip, Tar and BZip2 are create-and-extract only. DCL and LZW are decompression only. The library does not read or write RAR, 7z, XZ, Zstandard, LZ4, Snappy or Brotli, and it cannot extract Zip entries stored with the legacy Zip "Implode" (method 6) or "Shrink" (method 1) compression methods.
Sample Code
Create a Zip Archive
using CodeBrix.Compression.Zip;
using var fileStream = File.Create("archive.zip");
using var zipStream = new ZipOutputStream(fileStream);
zipStream.SetLevel(9); // 0-9, 9 being the highest level of compression
var entry = new ZipEntry("document.txt")
{
DateTime = DateTime.Now
};
zipStream.PutNextEntry(entry);
var buffer = File.ReadAllBytes("document.txt");
zipStream.Write(buffer, 0, buffer.Length);
zipStream.CloseEntry();
zipStream.Finish();
Create an AES-Encrypted Zip Archive
using CodeBrix.Compression.Zip;
using var fileStream = File.Create("encrypted.zip");
using var zipStream = new ZipOutputStream(fileStream);
zipStream.SetLevel(9);
zipStream.Password = "my-secret-password";
var entry = new ZipEntry("confidential.txt")
{
AESKeySize = 256, // Use AES-256 encryption
DateTime = DateTime.Now
};
zipStream.PutNextEntry(entry);
var buffer = File.ReadAllBytes("confidential.txt");
zipStream.Write(buffer, 0, buffer.Length);
zipStream.CloseEntry();
zipStream.Finish();
Extract a Zip Archive
using CodeBrix.Compression.Zip;
using var fileStream = File.OpenRead("archive.zip");
using var zipStream = new ZipInputStream(fileStream);
ZipEntry entry;
while ((entry = zipStream.GetNextEntry()) != null)
{
Console.WriteLine($"Extracting: {entry.Name} ({entry.Size} bytes)");
using var outputStream = File.Create(entry.Name);
zipStream.CopyTo(outputStream);
}
Read a Zip Archive with ZipFile
using CodeBrix.Compression.Zip;
using var zipFile = new ZipFile("archive.zip");
foreach (ZipEntry entry in zipFile)
{
if (!entry.IsFile) continue;
Console.WriteLine($"{entry.Name} - {entry.Size} bytes");
using var stream = zipFile.GetInputStream(entry);
using var reader = new StreamReader(stream);
var content = reader.ReadToEnd();
Console.WriteLine(content);
}
Create and Extract with FastZip
using CodeBrix.Compression.Zip;
var fastZip = new FastZip
{
CreateEmptyDirectories = true,
Password = "optional-password",
EntryEncryptionMethod = ZipEncryptionMethod.AES256
};
// Create a zip from a directory
fastZip.CreateZip("backup.zip", @"C:\MyFolder", recurse: true, fileFilter: null);
// Extract a zip to a directory
fastZip.ExtractZip("backup.zip", @"C:\Extracted", fileFilter: null);
GZip Compression
using CodeBrix.Compression.GZip;
// Compress a file
GZip.Compress(File.OpenRead("data.txt"), File.Create("data.txt.gz"), isStreamOwner: true);
// Decompress a file
GZip.Decompress(File.OpenRead("data.txt.gz"), File.Create("data.txt"), isStreamOwner: true);
Tar Archive
using CodeBrix.Compression.Tar;
// Create a tar archive
using var outStream = File.Create("archive.tar");
using var tarArchive = TarArchive.CreateOutputTarArchive(outStream);
var tarEntry = TarEntry.CreateEntryFromFile("document.txt");
tarArchive.WriteEntry(tarEntry, recurse: false);
tarArchive.Close();
BZip2 Compression
using CodeBrix.Compression.BZip2;
// Compress
BZip2.Compress(File.OpenRead("data.txt"), File.Create("data.txt.bz2"), isStreamOwner: true, level: 9);
// Decompress
BZip2.Decompress(File.OpenRead("data.txt.bz2"), File.Create("data.txt"), isStreamOwner: true);
DCL (PKWARE Data Compression Library) Decompression
using CodeBrix.Compression.Dcl;
// Decompress a DCL "imploded" stream (e.g. data produced by the implode()
// function of the PKWARE Data Compression Library, common in MS-DOS-era
// installer archives). Note: this is NOT the Zip "Imploded" (method 6) format.
using var inStream = new DclInputStream(File.OpenRead("data.imploded"));
using var outStream = File.Create("data.bin");
inStream.CopyTo(outStream);
LZW (.Z) Decompression
using CodeBrix.Compression.Lzw;
// Decompress a .Z stream written by the classic Unix compress utility.
// LzwInputStream is read-only and forward-only; there is no LzwOutputStream,
// because compression to .Z is not supported.
using var inStream = new LzwInputStream(File.OpenRead("data.Z"));
using var outStream = File.Create("data.bin");
inStream.CopyTo(outStream);
A .tar.Z file is a tar archive wrapped in a single .Z stream, so one stream
goes inside the other:
using CodeBrix.Compression.Lzw;
using CodeBrix.Compression.Tar;
using var lzwStream = new LzwInputStream(File.OpenRead("archive.tar.Z"));
using var tarArchive = TarArchive.CreateInputTarArchive(lzwStream, null);
tarArchive.ExtractContents("output-folder");
Documentation
The NuGet package includes AGENT-README.txt, a complete API reference and usage guide written for AI coding agents - point your agent at that file when it is writing code against this library.
Significant additional sample code is available in the CodeBrix.Compression.Tests project:
https://github.com/ellisnet/CodeBrix.Compression/tree/main/tests/CodeBrix.Compression.Tests
Note that the test project has InternalsVisibleTo access to the library, so a few of the helpers it uses are internal and are not available to package consumers.
License
CodeBrix.Compression is licensed under the MIT License - see the LICENSE file.
For licensing and provenance information about the open source code included in this package, see THIRD-PARTY-NOTICES.txt.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
-
net10.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on CodeBrix.Compression.MitLicenseForever:
| Package | Downloads |
|---|---|
|
CodeBrix.PdfDocuments.MitLicenseForever
CodeBrix.PdfDocuments is an Open Source .NET 10 (and higher) library that easily creates and processes PDF documents. The same drawing routines can be used to create PDF documents, draw on the screen, or send output to any printer. |
|
|
CodeBrix.Platform.GameEngine.MitLicenseForever
A fully managed, cross-platform 2D and 2.5D game engine for .NET, with tile maps, sprites, layered scenes, camera/view systems, animation, physics/collision, input, audio, and SkiaSharp rendering. Includes the CodeBrix.Platform host layer. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.248.1109 | 40 | 9/5/2026 |
| 1.0.238.89 | 325 | 8/26/2026 |
| 1.0.198.139 | 673 | 7/17/2026 |
| 1.0.174.95 | 186 | 6/23/2026 |
| 1.0.164.1268 | 166 | 6/13/2026 |
| 1.0.117 | 161 | 4/29/2026 |
| 1.0.49 | 265 | 2/27/2026 |
| 1.0.48 | 150 | 2/26/2026 |