nanoFramework.System.IO.Hashing
1.0.30
Prefix Reserved
dotnet add package nanoFramework.System.IO.Hashing --version 1.0.30
NuGet\Install-Package nanoFramework.System.IO.Hashing -Version 1.0.30
<PackageReference Include="nanoFramework.System.IO.Hashing" Version="1.0.30" />
paket add nanoFramework.System.IO.Hashing --version 1.0.30
#r "nuget: nanoFramework.System.IO.Hashing, 1.0.30"
// Install nanoFramework.System.IO.Hashing as a Cake Addin #addin nuget:?package=nanoFramework.System.IO.Hashing&version=1.0.30 // Install nanoFramework.System.IO.Hashing as a Cake Tool #tool nuget:?package=nanoFramework.System.IO.Hashing&version=1.0.30
Welcome to the .NET nanoFramework System.IO.Hashing Library repository
This repository contains the nanoFramework System.IO.Hashing class library.
Build status
Component | Build Status | NuGet Package |
---|---|---|
System.IO.Hashing |
System.IO.Hashing usage
CRC32 example
This implementation emits the answer in the Little Endian byte order so that the CRC residue relationship (CRC(message concat CRC(message)) is a fixed value). For CRC-32, this stable output is the byte sequence { 0x1C, 0xDF, 0x44, 0x21 }, the Little Endian representation of 0x2144DF1C.
[!WARNING] There are multiple, incompatible, definitions of a 32-bit cyclic redundancy check (CRC) algorithm. When interoperating with another system, ensure that you are using the same definition. The definition used by this implementation is not compatible with the cyclic redundancy check described in ITU-T I.363.5.
Computing a CRC32 for a byte array
var testData = new byte[] { 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x26, 0x39, 0xF4, 0xCB };
Crc32 crc32 = new Crc32();
crc32.Append(testData);
ConsoleWriteline($"CRC32 for test data is: {crc32.GetCurrentHashAsUInt32()}");
An alternative (static) API could be used instead.
var testData = new byte[] { 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x26, 0x39, 0xF4, 0xCB };
var computedHash = Crc32.HashToUInt32(testData)
ConsoleWriteline($"CRC32 for test data is: {computedHash}");
Computing a CRC32 for several data chunks
var testData1 = new byte[] { 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x26, 0x39, 0xF4, 0xCB };
var testData2 = new byte[] { 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0xD9, 0xC6, 0x0B, 0x34 },
Crc32 crc32 = new Crc32();
crc32.Append(testData1);
crc32.Append(testData2);
ConsoleWriteline($"CRC32 for test data is: {crc32.GetCurrentHashAsUInt32()}");
In case the Crc32
object needs to be reused, it's a matter of resetting the hash calculator with a call to Reset()
.
Computing a CRC32 for strings
This can easily be accomplished by extrating the byte representation of a string. Note that this requires adding a reference to nanoFramework.System.Text
.
var computedHash = Crc32.HashToUInt32(Encoding.UTF8.GetBytes("The quick brown fox jumps over the lazy dog"))
ConsoleWriteline($"CRC32 for the string is: {computedHash}");
Feedback and documentation
For documentation, providing feedback, issues and finding out how to contribute please refer to the Home repo.
Join our Discord community here.
Credits
The list of contributors to this project can be found at CONTRIBUTORS.
License
The nanoFramework Class Libraries are licensed under the MIT license.
Code of Conduct
This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behaviour in our community. For more information see the .NET Foundation Code of Conduct.
.NET Foundation
This project is supported by the .NET Foundation.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net is compatible. |
-
- nanoFramework.CoreLibrary (>= 1.16.11)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.