Game Development Reference
Implementing a Checksum
to Protect Data Integrity
Where is the information?
Lost in data.
Where is the data?
Lost in the #@%!& database!
Nearly all software applications handle the manipulation of data through a trans-
mission medium. A transmission medium could be the registry, memory, disk
files, or a database, to name a few. Each medium handles and stores data in a dif-
ferent way, but every transmission medium is unreliable and has the potential to
fail. It is for this reason that the CRC-32 (Cyclic Redundancy Check) algorithm
came to be, which is used to verify that there has been no corruption or errors in
a data transmission. This algorithm is given arbitrary data of arbitrary length, and
computes a 32-bit checksum number representing the contents of the supplied
data, which is transmitted along with the data through the transmission medium
that is used. Once the data arrives at its destination, a new checksum is recalculated
on the data that was received, and it is compared to the checksum calculated before
the transmission. If the values match, the transmission most likely was successful,
but if the values do not match, you know that the transmission encountered an
error of some sort and the data received is incomplete, modified, or corrupted.