'What is the correct CRC value for a zero length check?

I have a CRC-32/ISO-HDLC calculation function which is coded in 'C'. It works fine in that if I feed it '123456789' it give the correct result 0xCBF43926. However what is the correct result I should get for the empty string '' ?

My function gives '0x00000000' which is understandable given the way the code is written. But the reference calculator I am checking against gives 0xD202EF8D !!

I am checking against this tool : https://crccalc.com/?crc=&method=crc32&datatype=ascii&outtype=hex

My code is based on this reference : https://www.rfc-editor.org/rfc/rfc1662 which uses a lookup table technique.

Some other online tools also give 0x0000 for zero length input. Which tool is correct on this subject ?



Solution 1:[1]

I am checking against this tool : https://crccalc.com/?crc=&method=crc32&datatype=ascii&outtype=hex

I am not convinced that this tool works for zero lengths. A value of 0x00000000 is correct for a zero length.

It does works correctly for me with all kinds of other data lengths and data.

Solution 2:[2]

There is a snag in the UI with regard to non-printable input. That's all.

You get 0xD202EF8D on https://crccalc.com/?crc=&method=crc32&datatype=ascii&outtype=hex, if there is a line feed character in the input field and input mode is hex. Remove the line feed, toggle between ASCII and HEX input and you'll see the expected 0x00000000.

Check the "Show processed data (HEX)" box to see the actual input processed.

All in all no problem here.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Gerhard
Solution 2 HerrB