I have quite a simple program to compute the CRC32 of input strings from stdin and for some reason I am not getting the CRC32, but the CRC32B.
Here is my code
int main( int argc, char *argv[] ) {
unsigned long crc=0L;
unsigned char *stdinput = malloc(1024);
crc = crc32( 0L, Z_NULL, 0 );
fgets(stdinput, 1024, stdin);
crc = crc32( crc, stdinput, strlen(stdinput) - 1 );
printf("%s 0x%08x\n", stdinput, crc );
}
I know there are overflow problems in the program, but that's not necessarily my issue.
The problem is the output is like so
echo test | ./crc32 results in 0xd87f7e0c
and not 0xaccf8b33 Verified here https://www.tools4noobs.com/online_tools/hash/
The output from zlib is definitely using CRC32B and not CRC32.
How would I modify this so I get the correct output?
I'm running this on a Debian 64 bit machine.
Any help with this would be greatly appreciated. Thank you.