Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CRC checks for files

I'm working with a small FAT16 filesystem, and I want to generate CRC values for indidual XML files which store configuration information. In case the data changes or is corrupted, I want to be able to check the CRC to determine that the file is still in it's original state.

The question is, how do I put the CRC value into the file, without changing the CRC value of the file itself? I can think of a couple solutions, but I think there must be a fairly standard solution for this issue.

like image 312
Danny Avatar asked Oct 28 '08 23:10

Danny


2 Answers

You could append the CRC value to the end of the file. Then, when computing the CRC value later for checking, omit the last four bytes.

like image 128
Greg Hewgill Avatar answered Sep 23 '22 08:09

Greg Hewgill


Define a header, generate the CRC of everything except the header then put the value in the header.

like image 43
PiedPiper Avatar answered Sep 22 '22 08:09

PiedPiper