Sunday, April 20, 2008

Fletcher Checksum C# Algorithm


protected virtual void CalculateFletcherChecksum(byte[] bytes)
{
   byte c0 = 0, c1 = 0;
   int count = 0;
   for (count = 0; count < bytes.Length; count++)
   {
      c1 += (c0 += bytes[count]);
   }
   bytes[bytes.Length - 2] = (byte)((c0 - c1) & 0xFF);
   bytes[bytes.Length - 1] = (byte)((c1 - 2 * c0) & 0xFF);
}

2 comments:

Lucas Sun said...

Is this one 16 bit Fletcher checksum algorithm? Thanks.

Amit Soni said...

hello i need 32 bit version of Fletcher's checksum. please help me to implement this.
Thnaks