.NET Micro上的CRC32实现

时间:2011-10-18 08:59:58

标签: crc32 .net-micro-framework

我一直在寻找可以在.Net Micro框架上使用的CRC32实现。我发现this implementation,但微框架尚未实现HashAlgorithm。什么是让这个工作的最好方法?

3 个答案:

答案 0 :(得分:2)

.net microframework有Utility.ComputeCRC方法,虽然我不确定实际使用什么算法。它肯定不会使用OP中的一个。 Utility.ComputeCRC

答案 1 :(得分:1)

尝试http://vbcity.com/cfs-file.ashx/__key/CommunityServer.Components.PostAttachments/00.00.47.04.55/CRC_5F00_Lib.zip的CRC实施。这是http://vbcity.com/forums/t/111345.aspx讨论的实现。

您可以在http://www.lammertbies.nl/comm/info/crc-calculation.html验证CRC计算的正确性。

来自vbcity讨论的上述链接实际上实现了http://www.lammertbies.nl/comm/info/crc-calculation.html给出的c ++库的转换。

我发现这对我的CRC 16实现正常工作。

一个简短的代码段是

        ushort crcno = CRC.CRC16(stryourdata);
        Byte[] crcbytes = BitConverter.GetBytes(crcno);

答案 2 :(得分:1)

您可以使用您所指的代码。 HashAlgorithm仅用作接口,您可以删除它而不会损害CRC实现本身的功能。

更改“protected override void HashCore(byte [] buffer,int start,int length)” to“public void CalcCrc32(byte [] buffer,int start,int length)”。

public uint CrcValue应该不加改变地返回crcValue。

删除所有其他方法和属性。