I´ve got the following example:
3D020000000F0000112233445566778899AABBCCDDEEFF - Crc32 Input
280ACDA5 - Crc32 Result
But with the following Calculators: sunshine2k and zorc.breitbandkatze I can´t reconstruct the result. The documentation says: Polynomial-04C11DB7
, Reverse-EDB88320
, Initvalue-FFFFFFFF
and also the Result should not be reversed.
I´ve searched for libraries on NuGet and found Nito but do not get the right result either. I´ve also tried every combination with flags and polynomials (04C11DB7
, EDB88320
).
Can someone tell what I´m doing wrong? Are the calculators and the lib wrong? Also I´ve tried same combination of polinom and flags on both sides and the lib but got different result :-( may someone tell a lib which is definatly reight?
Here my Testcode:
[Theory]
[InlineData("3D 00 00 00 00 10 00 00 23 00 00 00 00 00 00 08 12 34 56 78 00 00 00 00", "7B 8A 60 0F")]
[InlineData("3D020000000F0000112233445566778899AABBCCDDEEFF", "280ACDA5")]
public void Crc32_Test(string input, string assumedCrc32)
{
var definition = new Definition
{
Initializer = 0xFFFFFFFF,
TruncatedPolynomial = 0xEDB88320,
ReverseResultBeforeFinalXor = false,
ReverseDataBytes = false,
};
var whow = new Nito.HashAlgorithms.CRC32(definition);
var inputArray = DESFireSessionHandler.StringToByte(input);
var assumedCrc32Array = DESFireSessionHandler.StringToByte(assumedCrc32);
var crc32 = whow.ComputeHash(inputArray);
if (crc32.SequenceEqual(assumedCrc32Array))
Assert.True(true);
else if (crc32.Reverse().SequenceEqual(assumedCrc32Array))
Assert.True(true);
else Assert.False(true);
}