A checksum is a device used to establish the integrity of data.
More specifically, a checksum is a value which is calculated based on
some data which, later, can be used to verify that the data used to
generate it remains unchanged. Usually this is accomplished by adding
the checksum to the sum of the data values and verifying the result.
For example, the Intel object file specification calls for a one byte
checksum at the end of every record in the file. This checksum is
stored in the last byte of each record and is defined to be the two's
compliment of the sum of the values of all other bytes in the record
modulo 256. That is, the sum of all bytes in a record modulo 256
added to the checksum byte's value should yield a value of zero. If
it does not, either the checksum byte or some other byte in the record
must have been corrupted.
This is, of course, not a foolproof method of detecting corruption.
If two bytes in an Intel object file are changed in such a way as to
compliment each other the corruption will remain undetected by the
checksum.
In order to increase the error detection ability of a checksum
algorithm more than one checksum value can be generated. Further,
what is known as a weighted checksum can be computed instead.
|