Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

different crc32 result from crccalc.com/ #15

Closed
Brandonn-Etheve opened this issue Jan 27, 2022 · 5 comments
Closed

different crc32 result from crccalc.com/ #15

Brandonn-Etheve opened this issue Jan 27, 2022 · 5 comments
Assignees
Labels
question Further information is requested

Comments

@Brandonn-Etheve
Copy link

Running included crc32 example sketch on an arduino uno i get:

/home/brd/Arduino/libraries/CRC/examples/CRC32_test/CRC32_test.ino
89A1897F
89A1897F
89A1897F
CDBAC17A
18

while https://crccalc.com/ with "123456789" input: ascii, output: hex, i get: 0xCBF43926

here the crccalc result link

What i'm missing?

@RobTillaart
Copy link
Owner

RobTillaart commented Jan 27, 2022

I'll have a look
...

Got the same results as you (so it is at least consistent)
CRC32_test.ino
89A1897F
89A1897F
89A1897F
CDBAC17A
18

These are the settings, these are NOT in the table at crccalc.com

void CRC32::reset()
{
  _polynome   = CRC32_DEFAULT_POLYNOME;  (== 0x04C11DB7)
  _startMask  = 0;
  _endMask    = 0;
  _crc        = 0;
  _reverseIn  = false;
  _reverseOut = false;
  _started    = false;
  _count      = 0;
}

Checking with - http://zorc.breitbandkatze.de/crc.html
and values seems OK.

image

Think you missed the XOR with 0xFFFFFF at the end (in the crccalc table)

@RobTillaart
Copy link
Owner

RobTillaart commented Jan 27, 2022

CDBAC17A is the CRC-32 when adding the string 123456789 twice.

@Brandonn-Etheve
Copy link
Author

Thanks for your time.
since there was a comment in the example sketch : // Serial.println("Verified with - https://crccalc.com/\n");
i though that the default setting should match the output of that website.

Using:
crc.setPolynome(0x04C11DB7);
crc.setStartXOR(0xFFFFFFFF);
crc.setEndXOR(0xFFFFFFFF);
crc.setReverseIn(true);
crc.setReverseOut(true);

the output is CBF43926 as expected.
since many website use those setting (including https://crc32.online/ and other) maybe you should use it as default setting, or add the link to http://zorc.breitbandkatze.de/crc.html instead of https://crccalc.com in the sketch comment.
Anyways issue solved.

@RobTillaart
Copy link
Owner

Good point to use at least a setting that is in the table.
I'll make a note of it for a next release to improve the examples.

Might be useful to have a dump() function to print all settings at once. => easier to check them.

@RobTillaart RobTillaart self-assigned this Jan 27, 2022
@RobTillaart RobTillaart added the question Further information is requested label Jan 27, 2022
@RobTillaart
Copy link
Owner

FYI triggered by your question I created a 0.2.0 version

  • Added getters for the parameters in the CRC classes so they become easier to verify programmatically.
  • Reduced the calls to yield() in add(array, length) to improve performance.
    now one in every 256 additions yield is called()..
  • minor edits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants