Calculating the CRC of a file
Author Message
Calculating the CRC of a file

Any one have sample code or tutorial to calculate the crc of a file
any help would be greatly appreciated

Tue, 27 Nov 2001 03:00:00 GMT
Calculating the CRC of a file
Try this 32 bit CRC code...

'****************************************************************************
'PBCRC32.BAS - powerbasic 3.2 CRC-32 Routine

'FileName\$ = "\PB32\PB.EXE"
'a1??? = FileCRC32???(FileName\$)
'print "CRC of " FileName\$ " = " hex\$(a1??? \ &H0FFFF) ":" hex\$(a1???
and &H0FFFF)

'****************************************************************************
FUNCTION FileCRC32??? (FileName\$)

if isfalse len(dir\$(FileName\$)) then exit function

Handle% = FREEFILE
OPEN FileName\$ FOR BINARY lock shared AS Handle%
CRC??? = &HFFFFFFFF
FOR aa% = 1 TO LOF(Handle%) \ LoadBuffer%
CRC??? = PBCRC32???(bb\$, CRC???)
NEXT
CRC??? = PBCRC32???(bb\$, CRC???)
CLOSE Handle%

FileCRC32??? = NOT CRC???                      'return CRC to
caller
END FUNCTION

FUNCTION PBCRC32???(BYVAL Target\$, BYVAL CRC???)
local length%, aa%
local CRCTable???()
'        static CRCTable???()

dim TargetPtr as byte Ptr
Length% = len(Target\$)
TargetPtr = StrPtr32(Target\$)

'       IF CRCTable???(1) = 0 THEN
dim CRCTable???(0:255)
restore CCITT32Table
FOR aa% = 0 TO 255
NEXT aa%
'       end if

FOR aa% = 1 TO Length%

(((CRC??? AND &HFFFFFF00) \ 256) AND &HFFFFFF)
incr TargetPtr
NEXT aa%
function = CRC???
END FUNCTION

CCITT32Table:   '(This table is CCITT-32 compatible.)
DATA &H000000000,&H077073096,&H0EE0E612C,&H0990951BA,&H0076DC419
DATA &H0706AF48F,&H0E963A535,&H09E6495A3,&H00EDB8832,&H079DCB8A4
DATA &H0E0D5E91E,&H097D2D988,&H009B64C2B,&H07EB17CBD,&H0E7B82D07
DATA &H090BF1D91,&H01DB71064,&H06AB020F2,&H0F3B97148,&H084BE41DE
DATA &H0646BA8C0,&H0FD62F97A,&H08A65C9EC,&H014015C4F,&H063066CD9
DATA &H0FA0F3D63,&H08D080DF5,&H03B6E20C8,&H04C69105E,&H0D56041E4
DATA &H0A2677172,&H03C03E4D1,&H04B04D447,&H0D20D85FD,&H0A50AB56B
DATA &H035B5A8FA,&H042B2986C,&H0DBBBC9D6,&H0ACBCF940,&H032D86CE3
DATA &H045DF5C75,&H0DCD60DCF,&H0ABD13D59,&H026D930AC,&H051DE003A
DATA &H0C8D75180,&H0BFD06116,&H021B4F4B5,&H056B3C423,&H0CFBA9599
DATA &H0B8BDA50F,&H02802B89E,&H05F058808,&H0C60CD9B2,&H0B10BE924
DATA &H02F6F7C87,&H058684C11,&H0C1611DAB,&H0B6662D3D,&H076DC4190
DATA &H001DB7106,&H098D220BC,&H0EFD5102A,&H071B18589,&H006B6B51F
DATA &H09FBFE4A5,&H0E8B8D433,&H07807C9A2,&H00F00F934,&H09609A88E
DATA &H0E10E9818,&H07F6A0DBB,&H0086D3D2D,&H091646C97,&H0E6635C01
DATA &H06B6B51F4,&H01C6C6162,&H0856530D8,&H0F262004E,&H06C0695ED
DATA &H01B01A57B,&H08208F4C1,&H0F50FC457,&H065B0D9C6,&H012B7E950
DATA &H08BBEB8EA,&H0FCB9887C,&H062DD1DDF,&H015DA2D49,&H08CD37CF3
DATA &H0FBD44C65,&H04DB26158,&H03AB551CE,&H0A3BC0074,&H0D4BB30E2
DATA &H0AA0A4C5F,&H0DD0D7CC9,&H05005713C,&H0270241AA,&H0BE0B1010
DATA &H0C90C2086,&H05768B525,&H0206F85B3,&H0B966D409,&H0CE61E49F
DATA &H05EDEF90E,&H029D9C998,&H0B0D09822,&H0C7D7A8B4,&H059B33D17
DATA &H073DC1683,&H0E3630B12,&H094643B84,&H00D6D6A3E,&H07A6A5AA8
DATA &H0E40ECF0B,&H09309FF9D,&H00A00AE27,&H07D079EB1,&H0F00F9344
DATA &H08708A3D2,&H01E01F268,&H06906C2FE,&H0F762575D,&H0806567CB
DATA &H0196C3671,&H06E6B06E7,&H0FED41B76,&H089D32BE0,&H010DA7A5A
DATA &H067DD4ACC,&H0F9B9DF6F,&H08EBEEFF9,&H017B7BE43,&H060B08ED5
DATA &H0D6D6A3E8,&H0A1D1937E,&H038D8C2C4,&H04FDFF252,&H0D1BB67F1
DATA &H0A6BC5767,&H03FB506DD,&H048B2364B,&H0D80D2BDA,&H0AF0A1B4C
DATA &H036034AF6,&H041047A60,&H0DF60EFC3,&H0A867DF55,&H0316E8EEF
DATA &H04669BE79,&H0CB61B38C,&H0BC66831A,&H0256FD2A0,&H05268E236
DATA &H0CC0C7795,&H0BB0B4703,&H0220216B9,&H05505262F,&H0C5BA3BBE
DATA &H0B2BD0B28,&H02BB45A92,&H05CB36A04,&H0C2D7FFA7,&H0B5D0CF31
DATA &H02CD99E8B,&H05BDEAE1D,&H09B64C2B0,&H0EC63F226,&H0756AA39C
DATA &H0026D930A,&H09C0906A9,&H0EB0E363F,&H072076785,&H005005713
DATA &H095BF4A82,&H0E2B87A14,&H07BB12BAE,&H00CB61B38,&H092D28E9B
DATA &H0E5D5BE0D,&H07CDCEFB7,&H00BDBDF21,&H086D3D2D4,&H0F1D4E242
DATA &H068DDB3F8,&H01FDA836E,&H081BE16CD,&H0F6B9265B,&H06FB077E1
DATA &H018B74777,&H088085AE6,&H0FF0F6A70,&H066063BCA,&H011010B5C
DATA &H08F659EFF,&H0F862AE69,&H0616BFFD3,&H0166CCF45,&H0A00AE278
DATA &H0D70DD2EE,&H04E048354,&H03903B3C2,&H0A7672661,&H0D06016F7
DATA &H037D83BF0,&H0A9BCAE53,&H0DEBB9EC5,&H047B2CF7F,&H030B5FFE9
DATA &H0CDD70693,&H054DE5729,&H023D967BF,&H0B3667A2E,&H0C4614AB8
DATA &H05D681B02,&H02A6F2B94,&H0B40BBE37,&H0C30C8EA1,&H05A05DF1B
DATA &H02D02EF8D

Quote:

>Any one have sample code or tutorial to calculate the crc of a file
>any help would be greatly appreciated

Lance
PowerBASIC Support

-------------------------------------------------------------------------
PowerBASIC, Inc.      | 800-780-7707 Sales | "We put the Power in Basic!"
316 Mid Valley Center | 831-659-8000 Voice | http://www.powerbasic.com

Wed, 28 Nov 2001 03:00:00 GMT
Calculating the CRC of a file
www.basicguru.com/abc/ a lot of programs for calculate CRC. See the
ALGORIThMS section.
some are written in ASM too.

--
Thomas Laguzzi

TLP Homepage
http://tlp.virtualave.net

Quote:
> Any one have sample code or tutorial to calculate the crc of a file
> any help would be greatly appreciated

Mon, 10 Dec 2001 03:00:00 GMT
Calculating the CRC of a file

........
crc
........

------------------------------

http://oak.oakland.edu/simtel.net/

arcutils/
luu213      7555  860428  v.buerg's test lbr w/CRC and sqz
c/
CRC-c       5067  870729  CRC routines for c
commprog/
fileutil/
32CRCfck   66618  960405  fileCRC does a cyclic redundancy check
brik.inf        2563  890731  description of brik CRC-32 program v2.0
brik2exe   20372  890712  general-purpose CRC-32 program, v2.0
brik2src   47859  890806  general-purpose CRC-32 pgm, v2.0, c source
CRC113     12682  900102  displays 16 and 32-bit CRC's of files
CRC67       4080  860927  calc. CRC value of files (opt'l. file output)
namnum1b   20001  960512  rename file to CRC32 of file contents
qCRC21     17225  871119  calculate CRC for ms-dos files
split60i   29692  980802  split & rebuild files with CRC verification
sum101      7932  890326  unix-like file CRC generation program
xsum11     34533  950208  computes CRC-32, md4 & md5 checksums of files
zkcheck    21562  960926  file-authentication program (CRC16 & CRC32)
pcmag/
v15n07    407487  960418  pcmag: CRC,getsize,idincr,oleau3,picalb,savncl
security/
CRCit100   47975  981006  generates ccitt CRC-32s of files/dirs/drives
turbopas/
CRC.pas         4671  851129  calculates xmodem CRCs
CRC2.pas       21600  860221  file CRC utility
CRCasm     13074  891028  asm CRC calculation code w/turbopas interfaces
virus/
CRCheck    28554  950424  generates and validates 32 bit checksums
CRCset13   32921  910711  self-scanning executable w/tp & msc/tc source
file-CRC   54976  881119  calculates CRCs for all files on a disk
fileCRC    40749  880718  detect if files have been corrupted
proveCRC   10425  880728  demo of CRC checking for file validity

------------------------------

ftp://garbo.uwasa.fi/pc/

arcutil/
luu213.lzh      v.buerg's test lbr w/CRC and sqz
c-lang/
CRCloc24    CRC security utility for c/c++ and gnu c progs, j.thorpe
filecopy/
shcpy201    copy files with read-after-write CRC verification
fileutil/
file-CRC    calculate CRCs for all files on a disk
goldies/
chksum16    calculates and checks 16-bit CRC checksums for files
pcmagvol/
vol15n07    contains disasm,getsize,idincr,oleau3,picalb,savncl,CRC
programming/
CRCset13    self-scanning executable with c and tp sources
sysutil/
brik2exe    calculate 32-bit CRC (usenet postings headers)
CRC113      CRC-m2 v1.13 (w c & asm)
turbopas/
tpschk11    turbo Pascal anti-hack CRC self check, m.durkin
---
n.b.
CONVERT ITS NAME TO   lowercase

--
=-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
al aab, seders moderator                                      sed u soon
it is not zat we do not see the  s o l u t i o n
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+

Wed, 12 Dec 2001 03:00:00 GMT

 Page 1 of 1 [ 5 post ]

Relevant Pages