| iMatix home page
| << | < | > | >>
SFL Logo SFL
Version 2.11

 

calculate_crc

#include "sflcryp.h"
qbyte
calculate_crc (byte *block, size_t length)

Synopsis

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.

Source Code - (sflcryp.c)

{
    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);
}

| << | < | > | >> iMatix Copyright © 1996-2000 iMatix Corporation