{"id":16626562,"url":"https://github.com/aloneguid/ironcompress","last_synced_at":"2025-10-25T10:03:07.006Z","repository":{"id":61246954,"uuid":"446376020","full_name":"aloneguid/ironcompress","owner":"aloneguid","description":".NET buffer compression library with native speed, supports gzip, snappy, brotli, zstd, lz4, lzo.","archived":false,"fork":false,"pushed_at":"2025-07-10T09:07:56.000Z","size":441,"stargazers_count":49,"open_issues_count":2,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-09-28T19:39:34.236Z","etag":null,"topics":["brotli","lz4","lzo","snappy","zstd"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aloneguid.png","metadata":{"files":{"readme":"docs/README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-01-10T10:25:53.000Z","updated_at":"2025-09-18T06:09:15.000Z","dependencies_parsed_at":"2024-01-22T17:02:22.774Z","dependency_job_id":"a3332cd7-8460-4adc-8733-a745950f4521","html_url":"https://github.com/aloneguid/ironcompress","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/aloneguid/ironcompress","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aloneguid%2Fironcompress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aloneguid%2Fironcompress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aloneguid%2Fironcompress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aloneguid%2Fironcompress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aloneguid","download_url":"https://codeload.github.com/aloneguid/ironcompress/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aloneguid%2Fironcompress/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280936359,"owners_count":26416544,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-25T02:00:06.499Z","response_time":81,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["brotli","lz4","lzo","snappy","zstd"],"created_at":"2024-10-12T04:10:52.333Z","updated_at":"2025-10-25T10:03:07.001Z","avatar_url":"https://github.com/aloneguid.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# IronCompress\n\n [![NuGet](https://img.shields.io/nuget/v/IronCompress.svg)](https://www.nuget.org/packages/IronCompress)\n\n\u003cimg src=\"icon.png\" width=80 height=80 align=\"left\"/\u003e C++ compression methods joined together in one native library, cross-compiled for multiple architectures and exposed as a .NET library. .NET has built-in support for **Gzip** and **Brotli** (which is what this library is using) but other compression methods are either available only as native libraries hard (impossible for some) to consume, or ill-ported C# alternatives. In fact, I myself [wrote one of them](https://www.aloneguid.uk/projects/ironsnappy/). Using native, original implementations is the way to go if you want to keep performance, security, and features up to date.\n\nThe library supports the following formats:\n\n- [Google Snappy](http://google.github.io/snappy/) [[source](https://github.com/google/snappy)].\n- [Facebook's Zstandard (zstd)](https://facebook.github.io/zstd/) [[source](https://github.com/facebook/zstd)].\n- [Gzip](https://www.gnu.org/software/gzip/) [[source](https://docs.microsoft.com/en-us/dotnet/api/system.io.compression.gzipstream?view=net-6.0)].\n- [Google Brotli](https://github.com/google/brotli) [[source](https://docs.microsoft.com/en-us/dotnet/api/system.io.compression.brotlistream?view=net-6.0)] (.net standard 2.0 build uses native version instead).\n- [LZO](http://www.oberhumer.com/opensource/lzo/) [[source](https://github.com/nemequ/lzo)].\n- [LZ4](https://lz4.github.io/lz4/) [[source](https://github.com/lz4/lz4)].\n\nAnd following architectures:\n\n| Format     | Managed                                                      |      | Windows | Linux | Mac OSX | ◀️ OS\u003cbr /\u003eArch 🔽 |\n| ---------- | ------------------------------------------------------------ | ---- | ------- | ----- | ------- | ---------------- |\n| **Snappy** | ✅\u003cbr /\u003e*\u003csup\u003evia [Snappier](https://github.com/brantburnett/Snappier) \u003c/sup\u003e* |      | ⛔       | ⛔     | ⛔       | x32              |\n|            |                                                              |      | ✅       | ✅     | ⛔       | x64              |\n|            |                                                              |      | ⛔       | ✅     | ✅       | ARM64            |\n| **Zstd**   | ✅\u003cbr /\u003e*\u003csup\u003evia [ZstdSharp](https://github.com/oleg-st/ZstdSharp)\u003c/sup\u003e* |      | ⛔       | ⛔     | ⛔       | x32              |\n|            |                                                              |      | ✅       | ✅     | ⛔       | x64              |\n|            |                                                              |      | ⛔       | ✅     | ✅       | ARM64            |\n| **Gzip**   | ✅\u003cbr /\u003e\u003csup\u003e*part of .NET*\u003c/sup\u003e                             |      | ⛔       | ⛔     | ⛔       | x32              |\n|            |                                                              |      | ⛔       | ⛔     | ⛔       | x64              |\n|            |                                                              |      | ⛔       | ⛔     | ⛔       | ARM64            |\n| **Brotli** | ✅\u003cbr /\u003e\u003csup\u003e*except on .NET Standard 2.0*\u003c/sup\u003e              |      | ⛔       | ⛔     | ⛔       | x32              |\n|            |                                                              |      | ✅       | ✅     | ⛔       | x64              |\n|            |                                                              |      | ⛔       | ✅     | ✅       | ARM64            |\n| **LZO**    | ⛔                                                            |      | ⛔       | ⛔     | ⛔       | x32              |\n|            |                                                              |      | ✅       | ✅     | ⛔       | x64              |\n|            |                                                              |      | ⛔       | ✅     | ✅       | ARM64            |\n| **LZ4**    | ⛔                                                            |      | ⛔       | ⛔     | ⛔       | x32              |\n|            |                                                              |      | ✅       | ✅     | ⛔       | x64              |\n|            |                                                              |      | ⛔       | ✅     | ✅       | ARM64            |\n\nI periodically update to the latest binaries. All the binaries are compiled from C/C++ source with `CMake` for major systems i.e. Linux, Windows and Mac OSX. They are then wrapped safely with a .NET interface.\n\n## Logic\n\nAlthough managed versions are available, they will be only used as a fallback when native library is not available, because native libraries are faster and more up to date with latest advancements.\n\nYou can check which version was used by reading `IronCompressResult.NativeUsed` flag.\n\n## Using\n\nThis library *only compresses buffers*. It may work with streams in the future, but I am currently only interested in buffers. Essentially, you pass `ReadOnlySpan\u003cbyte\u003e` as an input, and receive `Span\u003cT\u003e` as an output in the most efficient way.\n\nHere is an example of how to compress buffer with *snappy* codec:\n\n```csharp\nusing IronCompress;\t// root namespace\n\n// Construct library entry point and optionally pass an implementation of ArrayPool.\n// I will pass default shared pool here.\nvar iron = new Iron();\n\nbyte[] input = ...;\nusing(IronCompressResult compressed = iron.Compress(Codec.Snappy, input.AsSpan())) {\n    // ... use data\n}\n```\n\n`Compress`and `Decompress` methods actually return a `Result` class which wraps byte array of compression or decompression operation. You can access the underlying result by calling to `.AsSpan()` method inside the result. On dispose, `Result` makes sure the underlying memory is freed up - if pooling was used, it will be returned back to the pool.\n\nTo decompress:\n\n```csharp\nusing (IronCompressResult uncompressed = iron.Decompress(Codec.Snappy, compressed, input.Length)) {\n\t// ... use data\n}\n```\n\nAs with compression, this returns `Result` with decompressed data. It's worth nothing one important difference - decompression needs the length of output buffer specified as third parameter (`input.Length`). Although some decompressors can guess uncompressed length more or less correct, the others won't know it beforehand. In reality this problem is solved by using a framing format that adds metadata about resulting length, however many compression formats do not define that and consider compressed packets to be implementation specific.\n\nYou will need more or less recent C++ compiler, `CMake` and `.NET SDK 8` to build the code.\n\n\n## Building\n\nSee [workflow file](../.github/workflows/ci.yml) for building instructions.\n\nHint: To develop managed only code locally you can download the latest artifact from Actions output and put it into `native/ubin` so you have binaries for all platforms.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faloneguid%2Fironcompress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faloneguid%2Fironcompress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faloneguid%2Fironcompress/lists"}