I wish to use common CRC logic in a VB.NET or C# application as well as on a C/Linux application. I have one C/Linux application that interacts with a webservice (written in C#) and also a web application (written in VB.NET). For some data, I want to add a CRC to the data itself (say a file) from the .NET side and check for the integrity of the data (checking the CRC) on the client – and also vice-versa.
Can somebody please guide me?
Since CRC implementation is a one-liner, I don’t think you’ve have any problem with that. wikipedia has links to CRC source code in several different languages. The only thing you need to care about for portability is the endian-ness when you actually store the CRC in the file.
EDIT: Really, with a one-liner duplicating code is not going to be a problem.
C or C++ version
C# version
VB.NET version
To use a 16-bit CRC other than the CCITT, replace the lookup table. For a 32-bit CRC, replace all occurances of 16 with 32 and replace the lookup table.