I'm been stuck trying to write a CRC32 algorithm, mainly due to the lack of documentation anywhere… Here is my understanding how how it works…
>use 32 bit shift register, and 32 bit polynomial (technically 33 but MSB is not used for software calculations)
>initialize register to all 1's (or uint.maxvalue)
>shift each input byte into register 1 bit at a time, starting from the LSB
>if the value that gets discarded from register is 1, then XOR the register with the poly
>if not then do nothing for that bit.
>finally after all data is shifted into register, XOR the register (1's compliment), and that's the resulting CRC.
Seems simple enough, but when I actually try running it and comparing it to multiple CRC32 calculators online they don't match my result. I'm certain my polynomial is correct and certain my bitshifting and XORing works properly, I seem to be missing something.
P.s. I know practically all CRC32 calculators use a table of precalculated values, and thus all example programs use the lookup tables. I think its logical to learn how the basic CRC32 calculation works first… But there seem to be zero tutorials or explanations.