Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to calculate a CRC

0 views
Skip to first unread message

Nathan Mates

unread,
Feb 2, 1999, 3:00:00 AM2/2/99
to
In article <795lkk$rbq$1...@news.harvard.net>,
Aaron and Rebecca <spam...@nospam.com> wrote:
>I want to calculate a CRC for the datafiles in a game I'm working on. Can
>anyone explain how that is done, or point me to a good on-line reference?

I just searched on excite.com for "crc calculations", and found a
few hits immediately. [Other search engines can probably also find
similar and/or identical pages]
ftp://ftp.rocksoft.com/clients/rocksoft/papers/crc_v3.txt looked
interesting and might be useful.

General computing stuff like this can almost always be found faster
on a search engine than asking on a newsgroup

Nathan Mates

--
<*> Nathan Mates - personal webpage http://www.visi.com/~nathan/
# Network Programmer, Battlezone 2: see http://www.pandemicstudios.com
# NOT speaking for Pandemic Studios or Activision, ONLY myself
# "What are the facts, and to how many decimal places?" -R.A. Heinlein

Earl F. Glynn

unread,
Feb 2, 1999, 3:00:00 AM2/2/99
to
Aaron and Rebecca wrote in message <795lkk$rbq$1...@news.harvard.net>...
>x-no-archive: yes

>>I want to calculate a CRC for the datafiles in a game I'm working on. Can
>anyone explain how that is done, or point me to a good on-line reference?


Try:
www.efg2.com/lab/Mathematics/CRC.htm

efg
_________________________________
efg's Computer Lab: www.efg2.com/lab
Delphi Books: www.efg2.com/lab/TechBooks/Delphi.htm

Earl F. Glynn E-Mail: Earl...@att.net
Overland Park, KS USA


Matthias Benkmann

unread,
Feb 2, 1999, 3:00:00 AM2/2/99
to
>
>I want to calculate a CRC for the datafiles in a game I'm working on. Can
>anyone explain how that is done, or point me to a good on-line reference?

Send me email and I'll send you a small C++ class for calculating CRCs
of any length between 1 and 32 bits. MSB

Drake Christensen

unread,
Feb 3, 1999, 3:00:00 AM2/3/99
to
A call to produce a CRC is built into ZLIB.
http://www.cdrom.com/pub/infozip/zlib/

jrn

unread,
Feb 7, 1999, 3:00:00 AM2/7/99
to
Here is a VB example of creating a CCITT 16bit CRC. There are several different
ways of creating a CRC -- using different starting points and going in different
directions. This is just one way.. It's the modem used to calculate CRC's for
the XMODEM transfer protocol.. This function return in hex format a VB
string.....


You probably wont be using VB, but it demonstrates the algorithm..


Function CalcCRC16(buffer As String) As String


Dim crc As Long
Dim lp As Integer
Dim temp As Long

crc = 0

For lp = 1 To Len(buffer)

crc = crc And 65535
temp = Asc(Mid(buffer, lp, 1))
crc = (crc Xor (temp * 256))

For I = 1 To 8

crc = crc And 65535
If ((crc And 32768) <> 0) Then
crc = (crc * 2) Xor 4129
Else
crc = crc * 2
End If

Next I

Next lp

CalcCRC16 = Hex(crc And 65535)

' Make Sure the padding is correct
If Len(CalcCRC16) = 2 Then
CalcCRC16 = "0" + CalcCRC16
End If
If Len(CalcCRC16) = 3 Then
CalcCRC16 = "0" + CalcCRC16
End If

End Function

Aaron and Rebecca wrote:
>
> x-no-archive: yes


>
> I want to calculate a CRC for the datafiles in a game I'm working on. Can
> anyone explain how that is done, or point me to a good on-line reference?
>

> Thanks,
> Aaron.

--
==================================================================
Jim Norton --- jim.n...@worldnet.att.net
If a President of the United States ever lied to the American people he
should resign," --- William Clinton, 1974 while running for the US House of
Representatives responding to a question about President Nixon.

0 new messages