I Need Convert This Code To .net (C# or VB.net)
Please Help Me For Do This:I Need Convert This Code To .net (C# or VB.net)
Please Help Me For Do This:
word CalCRCCCITT(word val,byte data8)
{
byte tmp,i;
word CRC;
tmp = (val>>8)^data8;
CRC = 0;
for (i=8;i;i--)
{
if (0x8000&CRC)
{
CRC <<= 1;
CRC ^= 0x1021;
}
else
{
CRC <<= 1;
}
if (tmp&0x80)
CRC ^= 0x1021;
tmp <<= 1;
}
val <<= 8;
val ^= CRC;
return val;
}
word CalDemo(byte *tb_Bufp,byte tb_Len)
{
word tw_Val;
byte i;
tw_Val=0xffff;
for (i=0;i<tb_Len;i++)
{
tw_Val=CalCRCCCITT(tw_Val,(*tb_Bufp++) );
}
return tw_Val;
}
CCITT has standard CRC algorithms, so I bet there’s someone who has this code ready for you. A quick search on the net gave me the following articles:
http://www.codeproject.com/KB/cs/marcelcrcencoding.aspx
http://www.codeproject.com/KB/cs/csRedundancyChckAlgorithm.aspx
You’ll find more if you search for “C# ccitt crc”