NullFX.CRC 1.1.14

There is a newer version of this package available.
See the version list below for details.
dotnet add package NullFX.CRC --version 1.1.14
                    
NuGet\Install-Package NullFX.CRC -Version 1.1.14
                    
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="NullFX.CRC" Version="1.1.14" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NullFX.CRC" Version="1.1.14" />
                    
Directory.Packages.props
<PackageReference Include="NullFX.CRC" />
                    
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 NullFX.CRC --version 1.1.14
                    
#r "nuget: NullFX.CRC, 1.1.14"
                    
#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 NullFX.CRC@1.1.14
                    
#: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=NullFX.CRC&version=1.1.14
                    
Install as a Cake Addin
#tool nuget:?package=NullFX.CRC&version=1.1.14
                    
Install as a Cake Tool

NullFX CRC CI CodeQL NuGet

NullFX CRC is a small set of CRC utilities written in native C# released under the MIT License

NuGet:

GitHub Package Page

NuGet.org Package Page

Install

dotnet add package NullFX.CRC

Run this from the folder that contains your project file (or add the project path after dotnet add). The latest released version is installed; the NuGet badge above shows the current version.

Supported target frameworks: netstandard2.0, netcoreapp3.1, net40, net45, net46, net47, net48, net6.0, net7.0, net8.0 and net10.0.

Examples:

Each CRC library uses a common ComputeChecksum format. It accepts a byte array which can be obtained by converting text / numbers / structures etc into an array, then passing the byte array into ComputeChecksum for it's CRC.

The ComputeChecksum method also has a params argument parameter allowing individual bytes to be passed into the method one at a time rather than as an array.

If a checksum needs to be performed on a segment of an array, rather than creating a copy of the array to perform the CRC on, you can pass in the entire buffer and specify the section of the array in which to perform the CRC calculation, saving time and memory:

// using text
var text = "I am string content";
// convert text to a byte array
var textBuffer = System.Text.Encoding.UTF8.GetBytes ( text );

// get the CRC for the text
var textCrc = NullFX.CRC.Crc32.ComputeChecksum ( textBuffer );
Console.WriteLine ( "Text CRC: {0:X8}", textCrc );


// use a large number
var aNumber = 0xDEADBEEF;
// convert that to a byte array
var numberBuffer = System.BitConverter.GetBytes ( aNumber );

// get the CRC for the number
var numberCrc = NullFX.CRC.Crc32.ComputeChecksum ( numberBuffer );
Console.WriteLine ( "Number CRC: {0:X8}", numberCrc );


// bytes as params
var randomCrc = NullFX.CRC.Crc32.ComputeChecksum ( 0x01, 0x02, 0x03, 0x04 );
Console.WriteLine ( "Random bytes CRC: {0:X8}", randomCrc );


/// checksum of a subset of an array. perform the CRC on bytes at indices
// 2, 3, 4 and 5
var bytes = new byte[] { 0xFE, 0x2C, 0xED, 0x4B, 0x88, 0x31, 0x07, 0xBE };
var segmentedBytesCrc = Crc32.ComputeChecksum ( bytes, 2, 4 );
Console.WriteLine ( "Segment of bytes CRC: {0:X8}", segmentedBytesCrc );

Output:

Text CRC: 3AD00FD2
Number CRC: 1A5A601F
Random bytes CRC: B63CFBCD
Segment of bytes CRC: DB1A36A1

API Information

Crc8, and Crc32's ComputeChecksum have 2 different signatures

ComputeChecksum(byte[] bytes)

and

ComputeChecksum(byte[] bytes, int start, int length )

Crc16 has one additional initial parameter ( Crc16Algorithm ) where Crc16Algorithm is one of the following:

  • Standard CRC 16
  • CRC 16 CCITT with initial values of 0, FFFF and 1D0F
    • CRC 16 CCITT Kermit
  • Modbus

ComputeChecksum ( Crc16Algorithm algorithm, byte[] bytes )

and

ComputeChecksum ( Crc16Algorithm algorithm, byte[] bytes, int start, int length )

.

Note: this repository is also mirrored on GitLab

Benchmarks

BenchmarkDotNet ShortRun results from the release build for v1.1.14 on a GitHub-hosted runner. Absolute timings vary between runs and machines; compare rows within a table.


BenchmarkDotNet v0.15.8, Windows 11 (10.0.26100.33438/24H2/2024Update/HudsonValley) (Hyper-V)
AMD EPYC 9V45 2.60GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 10.0.401
  [Host]   : .NET 10.0.12 (10.0.12, 10.0.1226.42308), X64 RyuJIT x86-64-v4
  ShortRun : .NET 10.0.12 (10.0.12, 10.0.1226.42308), X64 RyuJIT x86-64-v4

Job=ShortRun  IterationCount=3  LaunchCount=1  
WarmupCount=3  

Method ArraySize Mean Error StdDev
NullFxCrc8 10 4.763 ns 1.911 ns 0.1048 ns
NullFxCrc16 10 9.130 ns 2.859 ns 0.1567 ns
NullFxCrc32 10 8.008 ns 6.848 ns 0.3754 ns
DataHashFunctionCrc8 10 43.019 ns 4.723 ns 0.2589 ns
DataHashFunctionCrc16 10 57.736 ns 38.380 ns 2.1037 ns
DataHashFunctionCrc32 10 62.859 ns 56.031 ns 3.0712 ns
NullFxCrc8 100 98.583 ns 12.475 ns 0.6838 ns
NullFxCrc16 100 203.283 ns 34.054 ns 1.8666 ns
NullFxCrc32 100 166.539 ns 47.917 ns 2.6265 ns
DataHashFunctionCrc8 100 244.388 ns 3.814 ns 0.2091 ns
DataHashFunctionCrc16 100 366.275 ns 15.016 ns 0.8231 ns
DataHashFunctionCrc32 100 377.354 ns 250.059 ns 13.7066 ns
NullFxCrc8 1000 1,399.143 ns 310.423 ns 17.0153 ns
NullFxCrc16 1000 2,032.177 ns 335.809 ns 18.4068 ns
NullFxCrc32 1000 1,804.730 ns 429.986 ns 23.5690 ns
DataHashFunctionCrc8 1000 2,357.015 ns 3,789.983 ns 207.7418 ns
DataHashFunctionCrc16 1000 3,414.401 ns 1,816.789 ns 99.5843 ns
DataHashFunctionCrc32 1000 3,399.439 ns 378.077 ns 20.7237 ns
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 is compatible.  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 is compatible.  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 is compatible.  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 is compatible. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net40 is compatible.  net403 was computed.  net45 is compatible.  net451 was computed.  net452 was computed.  net46 is compatible.  net461 was computed.  net462 was computed.  net463 was computed.  net47 is compatible.  net471 was computed.  net472 was computed.  net48 is compatible.  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.
  • .NETCoreApp 3.1

    • No dependencies.
  • .NETFramework 4.0

    • No dependencies.
  • .NETFramework 4.5

    • No dependencies.
  • .NETFramework 4.6

    • No dependencies.
  • .NETFramework 4.7

    • No dependencies.
  • .NETFramework 4.8

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.
  • net10.0

    • No dependencies.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on NullFX.CRC:

Package Downloads
TwitterStream

Stream twits without twitter api

Eyu.Audio

Package Description

rct

Library to talk with rct power inverters

Com.Ve.ServerDataReceiver

Package Description

Arsemi-Core

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.15 349 10/9/2026
1.1.14 90 10/9/2026
1.1.13 325 10/9/2026
1.1.10 238,224 10/9/2023
1.1.9 300 10/9/2023
1.1.8 32,716 7/7/2023
1.1.7 17,077 3/22/2023
1.1.6 8,922 2/8/2023
1.1.5 8,964 7/12/2022
1.1.4 5,854 4/30/2022
1.1.3 2,338,455 11/4/2021
1.1.2 5,716 5/7/2021
1.1.1 7,293 9/17/2020
1.0.1 75,717 2/23/2018
1.0.0 2,307 11/3/2017