ZRA.NET is a ZStandard Random Access (ZRA) wrapper library for .NET 5.0, written in C#
ZRA allows random access inside an archive compressed using ZStandard
See ZRA#Format for more info
- In-Memory
byte[] compressedData = Zra.Compress(dataToCompress, compressionLevel: 9, frameSize: 131072);
- Streaming
using (ZraCompressionStream compressionStream = new ZraCompressionStream(outStream, (ulong)inStream.Length, compressionLevel: 9, frameSize: 131072)) { inStream.CopyTo(compressionStream); // You must call Dispose() to write the ZRA header to the output stream. }
- In-Memory
byte[] decompressedData = Zra.Decompress(compressedData);
- Streaming
using (ZraFullDecompressionStream decompressionStream = new ZraFullDecompressionStream(inStream)) { decompressionStream.CopyTo(outStream); }
NOTE: offset
and count
are of the original uncompressed data.
- In-Memory
byte[] decompressedData = Zra.DecompressSection(compressedData, offset, count);
- Streaming
using (ZraDecompressionStream decompressionStream = new ZraDecompressionStream(inStream)) { byte[] decompressedSection = new byte[count]; decompressionStream.Read(decompressedSection, offset, count); }
We use a simple 3-clause BSD license located at LICENSE for easy integration into projects while being compatible with the libraries we utilize