0

I was looking for a CRC32 implementation I could use on the .Net Micro framework. I found this implementation, but the micro framework has not yet implemented the HashAlgorithm. What would be the best way to get this working ?

pritaeas
  • 2,073
  • 5
  • 34
  • 51

3 Answers3

2

.net microframework has Utility.ComputeCRC method albeit I am not sure about what algorithm actually uses. It certainly doesn't use one from OP. Utility.ComputeCRC

Miha Markic
  • 3,158
  • 22
  • 28
1

Try the CRC implementation from http://vbcity.com/cfs-file.ashx/__key/CommunityServer.Components.PostAttachments/00.00.47.04.55/CRC_5F00_Lib.zip . This is an implementation discussed at http://vbcity.com/forums/t/111345.aspx.

You can verify the correctness of your CRC calculations at http://www.lammertbies.nl/comm/info/crc-calculation.html.

The above mentioned link from vbcity discussion actually implements conversion of a c++ library given by http://www.lammertbies.nl/comm/info/crc-calculation.html.

I found this to work correctly for my CRC 16 implementation.

A short code snippet is

        ushort crcno = CRC.CRC16(stryourdata);
        Byte[] crcbytes = BitConverter.GetBytes(crcno);
Muthu
  • 2,675
  • 4
  • 28
  • 34
  • Thanks, looks promising indeed. Also found one other simpler implementation. I'll compare them, but I like the better options of this one. – pritaeas Oct 18 '11 at 09:53
  • Just to inform others, BitConverter.GetBytes is not available on the Micro Framework (yet). – pritaeas Oct 18 '11 at 10:22
1

You can use the code you are referring to. HashAlgorithm is just used as an Interface and you can drop it without harming the functionality of the CRC implementation itself.

Change "protected override void HashCore(byte[] buffer, int start, int length)" to "public void CalcCrc32(byte[] buffer, int start, int length)".

public uint CrcValue should return crcValue unaltered.

Drop all other methods and properties.

Vms
  • 11
  • 1