Socket
Book a DemoInstallSign in
Socket

Zstd.NetFramework

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Zstd.NetFramework

A NuGet package for C# that wraps libzstd.dll for compression and decompression using Zstandard.

Source
nugetNuGet
Version
2.0.8
Version published
Maintainers
1
Created
Source

Zstd.NetFramework

Available on NuGet https://www.nuget.org/packages?q=Zstd.NetFramework Codacy Badge

This is a Wrappers based on P/Invoke implementations.

Functions implemented by calling facebook/zstd(release).

API

Zstd.Compress(byte[] src, int level)

Zstd.Decompress(byte[] src, int dstCapacity)

Zstd.CompressStream(Stream src, Stream dst, int level)

Zstd.DecompressStream(Stream src, Stream dst)

Zstd.CompressStream2SimpleArgs(Stream src, Stream dst, int level)

Zstd.DecompressStreamSimpleArgs(Stream src, Stream dst)

Zstd.FreeLibrary();

Demo

using CN.Lalaki.Zstd;
using System.IO;
using System;
// ...sample code
using (var cstream = File.OpenRead("path\\of\\example.zst"))
{
    MemoryStream destream = new MemoryStream();
    // Decompress Stream
    Zstd.DecompressStream(cstream, destream);
    var c2stream = new MemoryStream();
    destream.Seek(0, SeekOrigin.Begin);
    // Compress Stream
    Zstd.CompressStream(destream, c2stream, 3);
    // Decompress Byte Array
    const int bufferSize = 1024 * 1024 * 20; // if 20MB, must be larger than original file size
    var dData = Zstd.Decompress(c2stream.ToArray(), bufferSize);
    Console.WriteLine("Decompress Size: {0}", dData.Length);
    // Compress Byte Array
    var cData = Zstd.Compress(dData, 3);
    Console.WriteLine("Compress Size {0}", cData.Length);
}

License

MIT

Keywords

zstd

FAQs

Package last updated on 01 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts