CRC Computation


Given a stream of data, or an array of bytes, this function computes a 32-bit checksum. The caller specifies the initial value of the checksum (CrcValue). Note that the caller can split the stream of data into substreams and call this subroutine for each of the substreams, passing in the result of the CRC computation from the previous substream as CrcValue.

 SUBROUTINE CRC(CrcValue, Array)
     CALL InitCrcCache()
     FOR each Byte from Array
         SET Index to CrcValue
         SHIFT Index right 24 bits
         Bitwise exclusive-OR Index with Byte
         SHIFT CrcValue left 8 bits
         Bitwise exclusive-OR CrcValue with Cache[Index]
     RETURN CrcValue