Check out this piece of code for packet checking in C#.
It compares the actual checksum with desired checksum on the basis of two parameters -
- Length
- Bit by bit checking with exit when a particular bit does not match.
public static bool CheckPacket(byte[] bMD5CheckSum, byte[] bActualCheckSum)
{
bool bSame = false;
if (bActualCheckSum.Length == bMD5CheckSum.Length)
{
int iIdx = 0;
do
{
if (bActualCheckSum[iIdx] != bMD5CheckSum[iIdx])
{
bSame = false;
break;
}
else
bSame = true;
iIdx++;
}
while (iIdx < bActualCheckSum.Length);
}
else
bSame = false;
return bSame;
}
HO HUM ☺
Comments