I use this trivial function to calculate the CRC checksum of a given file:
long i, j = 0;
int k = 0;
uint crc = 0xFFFFFFFF;
FileInfo file_info = new FileInfo(fil
This equation is key:
CRC(a XOR b) == CRC(a) XOR CRC(b)
Suppose you want to compute the CRC of the following message:
"Always desire to learn something useful."
There exist functions to compute the CRC as:
crc_join(crc_part1("Always desire to lea"),
crc_part2("rn something useful."))
If crc_part1
and crc_part2
zeros pad (\0
) their arguments as shown, crc_join
is just XOR.
crc_part1 = crc("Always desire to lea\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0")
crc_part2 = crc("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0rn something useful.")
The trailing zeros can be accounted for in crc_part1
with lookup tables. The leading zeros can be ignored in crc_part2
.
References: