There are many ways to implement data integrity verification. If it's memory, usually, you have a checksum. This is the simplest way of verifying data, and the less robust. But still, for memory, that is usually pretty good.
You start with zero, then you just take each byte/word/dword of memory and add it to the count. Don't worry if counter overflow, just keep the portion you want (ex: 16 bits chercsum, you keep 16 bits only).
For other data than memory, especially communication data, a simple checksum isn't usually enough. In this case, a CRC is used. The idea of a CRC is that usually, when an error occur on transmitted data, it usually affect a couple of bits close to each other, rather than being distributed across the whole packet. CRC is good at detecting bits error that occur in this fashion, and that's why Tx/Rx algorithm use CRC instead of checksum. And, the length of the CRC is usually dependent on the size of the packets. For a few bytes, a CRC8 is enough. For 1.6Kbyte, ethernet use a CRC32. Though, for checking memory, it's pretty good too.
For some source code, look at **broken link removed**
This is part of GNU software, but can be easily converted to other compiler by redifining uLong to 'unsigned long' or 'DWORD' under Windows.