|
| iMatix home page | << | < | > | >> |
SFLVersion 2.11 |
#include "sflcryp.h" qbyte calculate_crc (byte *block, size_t length)
Calculates the 32-bit CCITT CRC for a memory block. The CRC calculation is rapid, since the function uses a pre-calculated table. Returns the 32-bit CRC.
{
size_t
offset;
word
this_word;
qbyte
crc_value; /* Running CRC value */
crc_value = 0xFFFFFFFFL;
for (offset = 0; offset < length; offset++)
{
this_word = block [offset];
this_word = this_word ^ (dbyte) (crc_value & 255);
crc_value = (crc_value >> 8) ^ crc_table [this_word];
}
return (crc_value ^ 0xFFFFFFFFL);
}
| | << | < | > | >> |
|