[Solved] Why doesn’t my code return the checksum I am expecting and I pre-calculated?


I defined my checksum variable as unsigned long int because that was typedefed as a uint4 in the library I am porting (where the basis for this code comes from). Turns out that the library was only used on 32 bit architectures, so an unsigned long int is 4 bytes whereas on my machine (64 bit) it’s 8 bytes. Changing the variable to an unsigned int fixed everything, but I need to do a lot of work porting the library from 32 bit to 64 bit.

Also I should’ve used %lx instead of %x.

solved Why doesn’t my code return the checksum I am expecting and I pre-calculated?