All pastes #719128 Raw Edit

Untitled

public text v1 · immutable
#719128 ·published 2007-09-28 23:16 UTC
rendered paste body
uint32_t calc_crc(unsigned char* buf, int n)
{
    int i;
    uint32_t crc;

    crc = 0xffffffff;
    for (i=0; i < n ; i++)
    {
      // Both of these lines produce the same output:
      //        crc = EDC_crctable[(crc ^ buf[i]) & 0xff] ^ (crc >> 8);
      crc = ((crc >> 8) & 0xFFFFFF) ^ EDC_crctable[(crc & 0xff) ^ buf[i]];
    }
    crc ^= 0xffffffff;

    return crc;
}