Skip to content

C# bindings for the Windows native libraries of the Brotli compression algorithm.

Notifications You must be signed in to change notification settings

SergioLuis/Brotli-dot-NET

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 

Repository files navigation

Brotli-dot-NET

C# bindings for the Windows native libraries of the Brotli compression algorithm.
Re-wrote from XieJJ99/brotli.net with buffers in mind (instead of streams, but will likely support both in the future).


To compress a buffer:

byte[] flatBytes = GetMyAwesomeDataToCompress();
byte[] output = new byte[flatBytes.Length];

int outputLength = 0;
using (BrotliNET brotli = new BrotliNET(CompressionMode.Compress))
{
    brotli.Quality = 11;
    brotli.Window = 22;

    outputLength = brotli.Compress(flatBytes, 0, flatBytes.Length, output);
}

// The first 'ouputLength' bytes of the output buffer are the valid ones
WriteMyAwesomeCompressedData(output, output.Length);

To decompress a buffer:

byte[] compressedBytes = GetMyAwesomeDataToDecompress();
byte[] output = new byte[compressedBytes.Length * 4];

int outputLength = 0;
using (BrotliNET brotli = new BrotliNET(CompressionMode.Decompress))
{
    outputLength = brotli.Decompress(
          compressedBytes, 0, compressedBytes.Length, output);
}

// The first 'ouputLength' bytes of the output buffer are the valid ones
WriteMyAwesomeDecompressedData(output, output.Length);

About

C# bindings for the Windows native libraries of the Brotli compression algorithm.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • HTML 78.4%
  • C# 21.6%