IonKiwi.lz4.managed 1.0.5

.NET 6.0 .NET Standard 2.0
Install-Package IonKiwi.lz4.managed -Version 1.0.5
dotnet add package IonKiwi.lz4.managed --version 1.0.5
<PackageReference Include="IonKiwi.lz4.managed" Version="1.0.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add IonKiwi.lz4.managed --version 1.0.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: IonKiwi.lz4.managed, 1.0.5"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install IonKiwi.lz4.managed as a Cake Addin
#addin nuget:?package=IonKiwi.lz4.managed&version=1.0.5

// Install IonKiwi.lz4.managed as a Cake Tool
#tool nuget:?package=IonKiwi.lz4.managed&version=1.0.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

LZ4 for .NET (original C sources translated to C#)

LZ4 has been written by Yann Collet and the original sources can be found on https://github.com/lz4/lz4
This project contains the translated C# sources

How to use

non-streaming

Non streaming version, works with managed byte arrays, uses the LZ4 Framing Format (v1.6.1).
The compressed data that this stream creates is readable by the lz4 command line tools.

The Compress function has additional parameters to control the result.

  • blockMode: Linked or Independent blocks
  • blockSize: 64KB / 256KB / 1MB / 4MB
  • checksumMode: None / Content / Block
  • maxFrameSize: optional maximum frame size
  • highCompression: use lz4hc mode

Example:

  // compress data
  byte[] dataToCompress = ...
  byte[] compressedData = LZ4Utility.Compress(dataToCompress);
  // decompress data
  byte[] decompressedData = LZ4Utility.Decompress(compressedData);

streaming

Streaming version, uses the LZ4 Framing Format (v1.6.1).
The compressed data that this stream creates is readable by the lz4 command line tools.

Example:

  // compress data [with content checksum]
  using (LZ4Stream stream = LZ4Stream.CreateCompressor(innerStream, LZ4StreamMode.Write, LZ4FrameBlockMode.Linked, LZ4FrameBlockSize.Max64KB, LZ4FrameChecksumMode.Content)) {
    // write uncompressed data to the lz4 stream
	// the stream will compress the data and write it to the innerStream
	stream.Write(buffer, 0, buffer.Length);	
  }
  
  // compress data [with block and content checksum, start a new frame after 100 data blocks]
  // note: the lz4 command line tools do NOT support block checksums currently
  using (LZ4Stream stream = LZ4Stream.CreateCompressor(innerStream, LZ4StreamMode.Write, LZ4FrameBlockMode.Linked, LZ4FrameBlockSize.Max64KB, LZ4FrameChecksumMode.Block | LZ4FrameChecksumMode.Content, 100)) {
    // write uncompressed data to the lz4 stream
	// the stream will compress the data and write it to the innerStream
	stream.Write(buffer, 0, buffer.Length);	
  }
  
  // decompress data (in read mode)
  using (LZ4Stream stream = LZ4Stream.CreateDecompressor(innerStream, LZ4StreamMode.Read)) {
    // the lz4 stream will read the compressed data from the innerStream
    // and return the uncompressed data in 'buffer'
	int bytesRead = stream.Read(buffer, 0, buffer.Length);
  }
  
  // decompress data (in write mode)
  using (LZ4Stream stream = LZ4Stream.CreateDecompressor(innerStream, LZ4StreamMode.Write)) {
    // the lz4 stream will decompress the data from 'buffer'
	// and write the uncompressed data to the 'innerStream'
	stream.Write(buffer, 0, buffer.Length);
  }
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

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
1.0.5 540 12/28/2021
1.0.4 4,214 1/10/2021
1.0.3 5,272 6/28/2020
1.0.2 4,115 11/2/2019
1.0.1 301 10/22/2019
1.0.0 340 10/21/2019

removed .net5 tfm added .net 6.0