Problem A
I have an application that transfers data to another app via (serial/CAN/Ethernet/can-and-string/cheese stream ion a macaroni pipe/whatever). I have set up a send and acknowlege paradigm so I know when the receiver has all of the data, but I need to know that what the other end received is correct. What does the SDF do for me?
Problem B
I have an application that receives a file from a native application. The application send me a 'checksum' along with the data and the native guys tell me that I must use that checksum value to make sure that the data I received has not been corrupted. I vaguely understand what a checksum is, but I have no clue how to calculate one from the file. What does the SDF do for me?
Solution
[Tested on a custom PXA270-based Windows CE 5.0 device *and* the desktop (full framework 2.0)]
Nicely enough, the SDF solves both of these with the use of the OpenNETCF.CRC class. The CRC (short for Cyclic Redundancy Check) class supports generating a CRC for a byte array or a FileStream.
Here's what usage for a file looks like. This creates a 32-bit checksum (we support 8-64 bit) using a standard ploynomial (we support any custom polynomial too):
FileStream fs = File.OpenRead(sourceFileName);
uint checksum = (uint)OpenNETCF.CRC.GenerateChecksum(fs, 32, (ulong)OpenNETCF.CRCPolynomial.CRC_CCITT32);
fs.Close();