I’ve inherited a Delphi application which I need to convert to a C# application at my job.
One part uses what is supposed to be a CRC16 function in an external dll to create a checksum for some data. The problem is that this CRC which gets generated doesn’t match any of the CRCs ive managed to generate elsewhere.
I’ve tried about 10 different CRC code snippets which I found online, and have tried several online generators. The CRCs I generate match the ones I generate online, for example at –
http://www.lammertbies.nl/comm/info/crc-calculation.html
So my only conclusion now is that the Delphi application is not generating a valid CRC16 checksum. This leaves me with two options
1] Try to figure out which kind of CRC it is generating
2] Somehow call the functions in the DLL from inside C#
I’ve tried both and failed miserably.
—
All the source is on github –
https://github.com/delphi2sharp/delphisharp/blob/master/CRC16Test/CRC16Test/Program.cs
https://github.com/delphi2sharp/delphisharp/blob/master/DelphiCRC16Test/Unit1.pas
and the CRC.DLL is also there too.
—
Any help would be greatly appreciated.
Thanks
I think that you need a 2 phase approach.
1./ For the moment write an “unsafe/pInvoke” wrapper and call the native dll.
2./ Once the Delphi app is replaced and you control the encoding as well as the decoding, write a more standard CRC function.
Calling a native DLL is not that difficult, have a look at some of the examples at pinvoke.net.