Question: I am trying to do something that should be really simple, but I am stuck.

I am trying to add serial numbers (1,2,3 etc) to the items in Magento's invoice pdf under a column called Serial Number.

Any clues on how to do this?
Thanks!

Answer: 
First, a quick nomenclature correction - checksums and CRCs are 2 different approaches trying to solve the same problem: detect bit errors occurred during data transmission in noisy channels. In general CRCs are more powerful detecting errors at the expense of more complexity.

Selecting the right error detection scheme requires some knowledge about the channel (e.g. error probability) and its noise characteristics (e.g. impulsive, bursty). There are papers out there where this problem is analyzed in detail and some guidance is given in how to select the error detection method. I suggest you trying this introductory presentation as a starting point:

<http://www.ece.cmu.edu/~koopman/pubs/KoopmanCRCWebinar9May2012.pdf>

It will give you a better understanding of the complexity of this beautiful area and provide you some links to other learning materials.
Assuming that you have a good CRC or hash function that makes good use of the bits, and assuming that the expected sources of corruption do not have some unusual characteristics that invalidate the first assumption, then you can simply set an acceptable probability of a false positive, and get the number of bits from that. Or compute the probability from the bits and see if you're comfortable with that. The probability is:

p = 2-n

where *n* is the number of bits in the check value. That is the probability that an *n*-bit check value on some random data will accidentally match the *n*-bit check value on some other set of data.