How to get the same result in VBA and in PHP computing a CCITT CRC checksum

I was working last week on a Microsoft Access application and I needed to get some data from a webserver running Apache/PHP. Exchanging data with the server was easy, the WinHTTP and XML ActiveX library components are really cool and easy to use for that. But then I came unto some unexpected trouble when I tried to use a CRC check on both the VBA and PHP side to quickly add some integrity checking on the exchanged data.

I already had a VBA routine computing a CRC checksum, but had none on the PHP side. So I thought “google it up”, pick the first CRC checksum routine that comes up and use it, easy. By the way, if you want to refresh your neurons about the CRC stuff, you can read more about that in wikipedia.

To make a long story short, there are many algorithms out there, for VBA and PHP, and to find two that go well along and yield the same result, it takes some time and tries.

So, here are the two ones I now use. Enjoy !

VBA Cyclic redundancy check CRC16_2 function

And in PHP: