nullfx / nullfx.crc Goto Github PK
View Code? Open in Web Editor NEWNullFX CRC is a small set of CRC utilities (crc8, crc16, and crc32) written in C# and released under the MIT License
License: MIT License
NullFX CRC is a small set of CRC utilities (crc8, crc16, and crc32) written in C# and released under the MIT License
License: MIT License
// 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 );
How to get the result string with small character instead of capital character.
for "I am string content"
3ad00fd2 instad of value "3AD00FD2"
I check from online this site the result are return with small character CRC32 value.
Please add support for .NET Framework versions 4.0/4.5/4.6/4.7/4.8.
Hello
Is possible to make NullFX.CRC Targets .NET Standard 2.0?
That will make the library compatible with all .NET implementations specified here in one shot:
https://learn.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-2-0
This is useful when your library is integrated in another .NET Standard project to have a common base between .NET and .NET Framework.
Thanks
Hello, I try to use the Crc16Algorithm.CcittKermit, but its giving me wrong results.
var rawValue = 3218461.ToString();
var bytes = Encoding.UTF8.GetBytes(rawValue);
var raw = NullFX.CRC.Crc16.ComputeChecksum(Crc16Algorithm.CcittKermit, bytes);
var a = string.Format("0x{0:X}", NullFX.CRC.Crc16.ComputeChecksum(Crc16Algorithm.CcittKermit, bytes));
a result = 0xAAE0
But checking on https://crccalc.com/?crc=3218461&method=crc16&datatype=ascii&outtype=0 the result should be 0xE0AA
As you can see, the correct characters are there, just not in the right order and this happens for every input I throw at it. So my quickfix was just to do this: var fixedValue = $"{a[0]}{a[1]}{a[4]}{a[5]}{a[2]}{a[3]}"
; But it would be nice if the correct output comes out of the ComputedCheckSum methods.
I am not sure if I am doing something wrong with the package or that there is a bug? I have the feeling I am doing something wrong, but I have no experience in this area.
EDIT: fix for ComputeChecksum
raw = SwapBytes(raw );
var a = string.Format("0x{0:X}", raw );
public static ushort SwapBytes(ushort x)
{
byte[] bytes = BitConverter.GetBytes(x);
Array.Reverse(bytes);
return BitConverter.ToUInt16(bytes, 0);
}
NullFX.CRC/NullFX.CRC/Crc16.cs
Line 112 in 6d37378
If you have a 60 byte buffer and need to do a CRC on byte offsets 30-39, the CRC is not calculated.
The conditional check start < length
prevents the CRC from being calculated.
Example Call:
var crc = ComputeChecksum(myBytes, 30, 10);
I've tested out all of the algorithms, and I've been comparing them to CyberChef since that's the app I use the most (via https://gchq.github.io/CyberChef/)
Is CyberChef using a different type of CRC algo? Or am I missing a vital setting in yours. Because I've tested out about every variation of CRC16 I can, and I never get the values that I get in CyberChef.
However, CRC32 seems to be fine.
https://www.lammertbies.nl/comm/info/crc-calculation
It is very useful for industry communication.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.