Question

CRC-32 has this wonderful property that appending a CRC to the end of message allows you to perform verification of the message by calculating a CRC of the entire thing, and if the checksum passes, the final result will be zero.

Is this property supposed to hold true for CRC-32s sibling, the Adler32?

The short answer seems to be "No", but I just wanted to make sure I'm not missing something.

Using the example message here, http://en.wikipedia.org/wiki/Adler-32, I wrote the test program below using the zlib implementation

#include <zlib.h>
#include <stdio.h>
#include <string.h>

void print_sum( const char * str )
{
   uLong asum = 0;
   asum = adler32( 0, Z_NULL, 0 );
   asum = adler32( asum, str, strlen(str) );
   printf( "%x\n", asum);
}

int main (int argc, char** argv)
{
   const char * msg1 = "Wikipedia";
   const char * msg2 = "Wikipedia\x98\x03\xe6\x11";
   const char * msg3 = "Wikipedia\x11\xe6\x03\x98";

   print_sum( msg1 );
   print_sum( msg2 );
   print_sum( msg3 );
}

And these are the results:

11e60398
248c052a
23da052a
Was it helpful?

Solution

As you have found, the answer is no. That property is not needed for a check value. In fact most CRC check implementations don't run the CRC through at the end. They just check to see if the calculated CRC is equal to the stored CRC.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top