Crc32.NET 2.1.0

dotnet add package Crc32.NET --version 2.1.0
                    
NuGet\Install-Package Crc32.NET -Version 2.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Crc32.NET" Version="2.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Crc32.NET" Version="2.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Crc32.NET" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Crc32.NET --version 2.1.0
                    
#r "nuget: Crc32.NET, 2.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Crc32.NET@2.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Crc32.NET&version=2.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Crc32.NET&version=2.1.0
                    
Install as a Cake Tool

Crc32.NET

Optimized and fast managed implementation of Crc32 & Crc32C (Castagnoly) algorithms for .NET and .NET Core.

At this time, Microsoft released https://www.nuget.org/packages/System.IO.Hashing/ package with support of CRC32, so this package is for compatibility purposes. But it still really fast.

Installation through Nuget:

> Install-Package Crc32.NET

Version 1.1.0 Remarks

Initially, this library only support Crc32 checksum, but I found, that there are lack of .NET Core libraries for Crc32 calculation. So, I've added Crc32C (Castagnoli) managed implementation in this library. Other Crc32 variants (like Crc32Q or Crc32K) seems to be unpopular to implement it here.

So, if you need to use Crc32C for .NET Core, you can use this library. But if you only use 'big' .NET frameworks, it is better to use Crc32C.NET for Crc32C? because it has fast native implementation.

Version 1.2.0 Remarks

CRC algorithms has interesting feature: if we calculate it for some data and write result CRC data to end of source data, then calculate data with this CRC we'll receive a constant number. This number is 0x2144DF1C for CRC32 and 0x48674BC7 for CRC32C.

This feature can be used for more convenient CRC usage, e.g. validation of correctness is a simple comparison with constant. There are no requirement to decode CRC value from input array and compare it with calculated data.

So in 1.2.0 version, I've added 2 methods (with overloads) to use this feature:

var inputArray = new byte[realDataLength + 4];

// write real data to inputArray
Crc32Algorithm.ComputeAndWriteToEnd(inputArray); // last 4 bytes contains CRC

// transferring data or writing reading, and checking as final operation
if (!Crc32Algorithm.IsValidWithCrcAtEnd(inputArray))
{
    throw new InvalidOperationException("Data was tampered");
}

In other words, you should pass some input buffer to calculation function and it will write CRC data at last 4 bytes. After that, when you need validation, you should pass this buffer to validation function and it will return is data correct.

Version 2.0.0 Remarks

After long pause, project was updated to next major version. Changes:

  • Removed support for .net2.0 and .netstandard1.3
  • Added support for .net6.0
  • For core version ReadOnlySpan versions was added
  • Optimized CRC32 version for .net6.0
  • Intrinsic for CRC32C version for .net6.0

So, results now:

Algorithm framework Speed
CRC32(C) .net4.0 1090 MB/s
CRC32 .net6.0 1378 MB/s
CRC32C .net6.0 18128 MB/s

Other libraries were not checked now, it also can be already optimized.

Version 2.1.0 Remarks

  • CRC32 for .net6.0 now uses pclmulqdq to improve speed if supported and uses cast to uint if unsupported. It is SSE2 command, so, it should be supported at any modern cpu. for ARM binary primitives used also. Speed not checked

So, difference between old and new version:

Algorithm framework Speed
CRC32 at 2.0.0 .net6.0 1378 MB/s
CRC32 at 2.1.0 no pclmulqdq .net6.0 1560 MB/s
CRC32 at 2.1.0 supports pclmulqdq .net6.0 2772 MB/s

Idea of code from https://www.nuget.org/packages/System.IO.Hashing/

This is "maintenance" release with optimizations and new frameworks, but it not checked carefully and can be optimized more.

Description

This library is port of Crc32C.NET by Robert Važan but for Crc32 algorithm. Also, this library contains optimizations for managed code, so, it really faster than other Crc32 implementations.

If you do not not catch the difference, it is C (Castagnoli). I recommend to use Crc32C, not usual CRC32, because it can be faster (up to 20GB/s with native CPU implementation) and slightly better in error detection. But if you need exactly Crc32, this library is the best choice.

Performance (not checked for new versions of other packages)

This library has code, which is optimized for .NET (implementation is not dumb copy-paste from google), as result, it is really fast in comparison with other implemenations.

Library Speed
CH.Crc32 by Cliff Hammerschmidt 117 MB/s
Crc32 by Dario Griffo 401 MB/s
Klinkby.Checksum by Mads Breusch Klinkby 400 MB/s
Data.HashFunction.CRC by Brandon Dahler 206 MB/s
Dexiom.QuickCrc32 by Jonathan Paré 364 MB/s
K4os.Hash.Crc by Milosz Krajewski 399 MB/s
This library 2772 MB/s

Some notes

I thought about making a pull request to Crc32 library, but it seems, this library was abandoned. Anyway, I implement my library to be fully compatible with Crc32 library. And you can switch from Crc32 library to this.

Api interface was taken from Crc32C.NET library. It is very handy for using in applications.

License

MIT license

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net40 is compatible.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.0

    • No dependencies.
  • .NETStandard 2.0

  • net6.0

    • No dependencies.

NuGet packages (77)

Showing the top 5 NuGet packages that depend on Crc32.NET:

Package Downloads
Bitfinex.Net

A high-performance .NET client library for the Bitfinex REST and WebSocket APIs, providing strongly typed models, automatic WebSocket reconnection, client-side rate limiting, local order book support, and seamless integration with other CryptoExchange.Net based clients.

KrakenExchange.Net

A high-performance .NET client library for the Kraken REST and WebSocket APIs, providing strongly typed models, automatic WebSocket reconnection, client-side rate limiting, local order book support, and seamless integration with other CryptoExchange.Net based clients.

MiNET.LevelDB

LevelDB implementation for MiNET. Goal is to be able to read bedrock world-files stored in LevelDB and using zlib compression.

Pangea.SDK

.NET SDK to access Pangea API services on pangea.cloud

Apprio.Enablement.Business.Referrals.Telemetry

Package Description

GitHub repositories (26)

Showing the top 20 popular GitHub repositories that depend on Crc32.NET:

Repository Stars
JosefNemec/Playnite
Video game library manager with support for wide range of 3rd party libraries and game emulation support, providing one unified interface for your games.
LykosAI/StabilityMatrix
Multi-Platform Package Manager for Stable Diffusion
Davidobot/BetterJoy
Allows the Nintendo Switch Pro Controller, Joycons and SNES controller to be used with CEMU, Citra, Dolphin, Yuzu and as generic XInput
ArduPilot/MissionPlanner
Mission Planner Ground Control Station for ArduPilot (c# .net)
Valkirie/HandheldCompanion
A touch optimized GUI to increase your handheld gaming computer experience.
NethermindEth/nethermind
A robust, high-performance execution client for Ethereum node operators.
mattpannella/pupdate
Pupdate - A thing for updating your Analogue Pocket
LeagueSandbox/GameServer
League Sandbox's Game Server
n00mkrad/text2image-gui
Somewhat modular text2image GUI, initially just for Stable Diffusion
Unity-Technologies/UnityDataTools
Tools and libraries for reading and analyzing Unity data files.
dorisoy/Dorisoy.Pan
Dorisoy.Pan 是基于 .NET 10 的跨平台文档管理系统,使用 MS SQL 2012 / MySQL 8.0(或更高版本)后端数据库,您可以在 Windows、Linux 或 Mac 上运行它。项目中的所有方法都是异步的,支持 JWT 令牌身份验证,项目体系结构遵循 CQRS + MediatR 模式和最佳安全实践。源代码完全可定制,热插拔且清晰的体系结构,使开发定制功能和遵循任何业务需求变得容易。
RetroDriven/Pocket_Updater
Windows GUI Application to Update Cores for the Analogue Pocket
replaysMike/Binner
Open source parts inventory system for makers, electronics hobby, and professional engineers
n00mkrad/nmkoder
Media encoding, muxing, analysis toolkit for Windows
LANCommander/LANCommander
OpenKH/OpenKh
Kingdom Hearts libraries, tools, game engine and documentation
EricZimmerman/evtx
C# based evtx parser with lots of extras
xiyanxy/BetterJoy_CHS
提供任天堂系列手柄与Cemu(搭配Cemuhook)、Citra、Dolphin、Yuzu等模拟器以及系统范围通用的XInput(DS4)支持,汉化定制版本
CTR-tools/CTR-tools
Crash Team Racing (PS1) tools - a C# framework and a set of tools by DCxDemo to parse files found in the original kart racing game by Naughty Dog (and a bit of Crash Bash too).
MS2Community/Maple2
Server emulator for MapleStory2.
Version Downloads Last Updated
2.1.0 1,877 10/19/2026
2.0.0 1,357 10/16/2026
1.2.0 39,380,912 12/7/2017
1.1.0 48,616 7/13/2017
1.0.2 21,515 12/12/2016
1.0.1 5,320 9/24/2016
1.0.0 13,187 6/19/2016

* Removed support for .net2.0 and .netstandard1.3
* Added support for .net6.0
* For core version ReadOnlySpan versions was added
* Optimized CRC32 version for .net6.0
* Intrinsic for CRC32C version for .net6.0
* CRC32 for .net6.0 now uses pclmulqdq to improve speed