Date : Sun, 12 Jun 2011 03:14:56 +0100
From : jgh@... (J.G.Harston)
Subject: Calculating CRCs
Rick Murray wrote:
> Anything specific to zip files? It wasn't hard to track down 32 bit CRC
> code when I needed some.
I spent about four hours a couple of days ago thrashing the interweb
looking for code to update the CRC code in BBCZip, and failed. Just
try it yourself, enter "CRC-32" or "CRC32" into Gurgle. Plently of
'download a commandline utility to calculate a CRC-32 on a file',
or detail theoretical analysis of what polynomial CRC calculation is,
no actual code. The original CRC code in BBCZip was a very badly
mangled conversion of some C code that needed the CRC reversing, and
every byte reversing, and moving up 24 bits. I rewrote it from scratch
to avoid all the bit reversal and multiplication by &1000000. Ended
up with a 50% increase in speed, and the filesystem access is the
limiting speed factor now.
> 0x076DC419L, 0x706AF48FL, 0xE963A535L, 0x9E6495A3L,
> 0x0EDB8832L, 0x79DCB8A4L, 0xE0D5E91EL, 0x97D2D988L,
> 0x09B64C2BL, 0x7EB17CBDL, 0xE7B82D07L, 0x90BF1D91L,
I specifically *didn't* want a table version, I didn't want to a
program bloated with loads of table data that would just get copied
from the program into memory.
> The only problem here is that there are various types of CRC-16. I
I know, I've initially got the X-MODEM CRC-16 code which, again,
took loads of tracking down in about 1995. Searching would find
loads of results saying "product X uses XMODEM-CRC which is more
reliable as it uses a 16-bit CRC". Nothing about actually **WRITING**
a CRC calculator.
> valid CRC it wouldn't load. I think CCITT and X-Modem are subtly
> different.
CCITT goes b0...b7, X-Modem goes b7...b0 (or the other way around).
Sprow wrote:
> In the C implementation I don't see what
> crc &= 0xFFFFFFFF;
> does.
I'm not sure, that's from my original notes from the very first version
of BBCZip back in about 1997.
--
J.G.Harston - jgh@...