• #### Good One

Posted by Legacy on 12/16/2001 12:00am

Originally posted by: Dayanand Urs D

Hi
I was just going thru this site..I found ur code ..it was good...
Actually I wanted to something like this so i was searching on the net...I'm glad I found ur code...it saved lot of time for me...
thanks once more....
rgds

• #### Would it be possible for some kind person to...

Posted by Legacy on 11/27/2001 12:00am

Originally posted by: Tom

Im a newbie vc++6 user and Ive been looking a the source code and whilst exactly what I need I cant really figure which bits I need to extract to make my own version of this program. Im just after a plain command line
eg crc.exe <filename> but Im not too sure how to remove all of the extra bits. I want to implement the Static Assembler crc32 function...could anyone possibly help me?

Thanks :)
Tom

• #### anagramitic crcs query

Posted by Legacy on 09/29/2001 12:00am

Originally posted by: D.Deere

Does anyone know if the crc is the same if u use it on anagrams:
STOP = "Xa"
POTS = "Xa" or does it end up as "Xb"?
similarly,
TOPS = "Xa" or "Xc"
Further, IF IT IS a different CRC, does anyone know of a "functional relationship" (mathmatical) between
"Xa" & "X any n", given they are derived from the SAME letters(i'm assuming ASCII representations in binary at the lower levels) and that
A+B+C = C+A+B
no matter the order they are added,
and also A(B*C) = (A*B)C...im kinda new to programming and all this math, so looking for some basic pointers(groan).

FYI-im thinking of using such an approach to find anagrams in a given list, and thinking of using this method to "flag" words having the same crc/checksum(since its faster). Anyone having ideas how this might be done(if u have addressed such a challenge previously) are encouraged to email them to me. :-)

TIA,
D.

• #### Another good source of CRC32 code.

Posted by Legacy on 09/17/2001 12:00am

Originally posted by: Patrick Hoonhout

```I've found the following source to be very helpful. It's not asm, but it's portable and it's the fastest and tightest C source I've found. Table driven, 16 & 32bit CRC, and offers both byte and word alignment alternatives.

http://om.cse.unsw.edu.au/lxr/gdb/http/source/rdi-share/
look for crc.c and crc.h.

Source to generate the CRC table used in crc.c and crc.h
```

• #### Good Stuff Man!

Posted by Legacy on 09/12/2001 12:00am

Originally posted by: Joel Watson

Excellent Code ! I had lost my original source when I had written something like this many years back...this really looks tons better than what I remember writing! Thanks for the code my friend!!

Joel

• #### Thanks

Posted by Legacy on 09/10/2001 12:00am

Originally posted by: Eic Sanchez

Thanks for the article and the source code, just what i was looking for. I found an article that explains it in details but was too lazy to read it and make my own lib.

• #### I needed such a timerfunction ;-)

Posted by Legacy on 09/07/2001 12:00am

Originally posted by: The Blackbird

Thx

The Blackbird

• #### MapFileAndCheckSum problem

Posted by Legacy on 08/31/2001 12:00am

Originally posted by: Dani Nuestro

another note though, the MapFileAndCheckSum returns different CheckSum on a really identical file between WinNT and Win9x operating system. Try multiple files,speacially EXE and DLL files to see the result.

when i tried the sample code posted, the Checksum values of the files returned are identical.

• #### good

Posted by chenayuan on 10/17/2007 11:12pm

`good`

• #### Reflected CRCs

Posted by Legacy on 08/30/2001 12:00am

Originally posted by: Tim Smith

There are two very common implementations of CRC, normal and reflected.

Normal CRCs process the input data from LSb (bit) to MSb. You can see this in your table generation routine. Also, in a normal CRC, you are processing the LSB (byte) of the CRC each time. (Oh, btw, in theory, a CRC can be generated for a stream of bits of any length such as 3. It is the table lookup optimization that forces the byte limit.)

In a reflected CRC, the input data is processed from MSb to LSb. Now, you can make a reflected algorithm act normal by reversing the bit order of the input data and the input/output CRC values. However, this is REALLY slow.

To implement a reflected CRC, first reverse the polynomial. However, most of the time the polynomial is already reversed (which is why you see 0x04C11DB7 instead of 0xEDB88320.) Next, during table generation, instead of testing the low bit of the input byte, test the high bit and shift up instead of down.

Finally, in the table lookup, all you have to have is:

dwCrc32 = ((dwCrc32) << 8) ^ m_pdwCrc32Table[(byte) ^ (dwCrc32 >> 24)];

So, when you see a reversed CRC polynomial, that is a good hint that they are actually using a reflected CRC and not the normal type.

Of course, there is always some person who uses a reversed polynomial with a normal crc or normal polynomials with reflected crcs. But the good news is that reversed polynomials tend to work just as well.

Also, it is VERY VERY important that the seed value is set to something other than 0 (which it is in this code). If the seed is 0, then a stream of 10 or 23402490 NULL bytes will always yield a zero crc (excluding any final one's compliment.)