LzfseSharp 0.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package LzfseSharp --version 0.0.1
                    
NuGet\Install-Package LzfseSharp -Version 0.0.1
                    
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="LzfseSharp" Version="0.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LzfseSharp" Version="0.0.1" />
                    
Directory.Packages.props
<PackageReference Include="LzfseSharp" />
                    
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 LzfseSharp --version 0.0.1
                    
#r "nuget: LzfseSharp, 0.0.1"
                    
#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 LzfseSharp@0.0.1
                    
#: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=LzfseSharp&version=0.0.1
                    
Install as a Cake Addin
#tool nuget:?package=LzfseSharp&version=0.0.1
                    
Install as a Cake Tool

LzfseSharp

A C# port of Apple's LZFSE (Lempel-Ziv Finite State Entropy) compression algorithm. This library provides decoding-only functionality for decompressing LZFSE-compressed data.

What is LZFSE?

LZFSE is a Lempel-Ziv style data compression algorithm using Finite State Entropy coding, introduced by Apple with OS X 10.11 and iOS 9. It targets similar compression ratios to DEFLATE but with significantly higher compression and decompression speeds.

Features

  • Supports all LZFSE block types:
    • LZFSE compressed blocks (V1 and V2 with FSE encoding)
    • LZVN compressed blocks (simpler algorithm for small data)
    • Uncompressed blocks

Installation

dotnet add package LzfseSharp

Usage

Basic Decompression

using LzfseSharp;

// Read compressed data
byte[] compressedData = File.ReadAllBytes("data.lzfse");

// Allocate buffer for decompressed output
// You need to know the uncompressed size beforehand
byte[] decompressedData = new byte[uncompressedSize];

// Decompress
int bytesWritten = LzfseDecoder.Decompress(
    decompressedData,
    compressedData
);

if (bytesWritten == 0)
{
    Console.WriteLine("Decompression failed!");
}
else
{
    Console.WriteLine($"Decompressed {bytesWritten} bytes");
}

Working with Streams

using LzfseSharp;

using var inputStream = File.OpenRead("data.lzfse");
using var outputStream = File.OpenWrite("data.bin");

// Read compressed data
byte[] compressed = new byte[inputStream.Length];
inputStream.Read(compressed, 0, compressed.Length);

// Decompress
byte[] decompressed = new byte[uncompressedSize];
int bytesWritten = LzfseDecoder.Decompress(decompressed, compressed);

// Write decompressed data
if (bytesWritten > 0)
{
    outputStream.Write(decompressed, 0, bytesWritten);
}

LZFSE Format Overview

LZFSE uses a block-based structure where each block has a magic number identifier:

Magic Description
bvx$ (0x24787662) End of stream
bvx- (0x2d787662) Uncompressed block
bvx1 (0x31787662) LZFSE compressed (uncompressed tables)
bvx2 (0x32787662) LZFSE compressed (compressed tables)
bvxn (0x6e787662) LZVN compressed

The decoder automatically detects and handles all block types.

Limitations

  • Decode-only: This library only supports decompression. For compression, use the original C library or platform-specific APIs on Apple platforms.
  • No streaming API: Currently requires the entire compressed data in memory. Streaming support may be added in future versions.
  • Buffer size: You must allocate the output buffer with the correct uncompressed size beforehand.

License

This project is licensed under the BSD 3-Clause License - the same license as Apple's original LZFSE implementation. See the LICENSE file for details.

References

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 (2)

Showing the top 2 NuGet packages that depend on LzfseSharp:

Package Downloads
LTRData.DiscUtils.Dmg

DiscUtils dmg parser. Works with apple disk (.dmg) files

Devedse.DiscUtils.Dmg

DiscUtils dmg parser. Works with apple disk (.dmg) files

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 2,874 6/5/2026
1.0.0 176 5/11/2026
0.1.0 3,955 4/19/2026
0.0.1 197 2/16/2026