Solved

CRCs - Calculating them quickly for a File

Posted on 1997-06-20
4
374 Views
Last Modified: 2010-04-04

I have written some code to Calculate the CRCs of a bunch of files.

The trouble is that I have done all the CRC calculations using binary digits held in strings so it is VERY S.L.O.W. !!

I did it this way, because it makes the code so easy to understand - but the draw back is that it is slow !

I kind of started to convert my code over to using Integers and doing everything using Bitwise operators (SHL, XOR, etc) but (after my very early benchmarks) I didn't get the speed improvement I was desperate for.

The trouble is that my CRC code needs to be finished very quickly, so I have sort of run out of time.

I need some very fast code to calculate and return the CRC for a file, which I can then call for all files in my list.

I am not too fusy about whether 16 or 32 bit CRCs are calculated, as long as the code works under 16 and 32 bit Delphi and is fast.

Can anybody help ?

I have assigned a lot of points to this question to try and get some good quick help on this.

TIA
Moose
0
Comment
Question by:moose032797
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 3

Expert Comment

by:mheacock
ID: 1337332
It might be slow because you are reading from the disk file
often...

Try reading the entire file into an array of bytes...you can
do all this with two commands...a GetMem and then a read...
can't rmember what the read command is...I do remember seeing
it help...perhaps a stream??

Anyhow, if you do all your calculations in memory, then it
should be dramatically faster...
0
 

Author Comment

by:moose032797
ID: 1337333
No, I am reading 4 KB buffer at once, so it is definetely how I have done the calculations.

I have now converted my STRING based calculations to Long Integers - the problem now is + / - flipping of numbers.
For me, a 1 in the leftmost bit does not indicate a negative number - unfortunately, I don't know how to get around this under Delphi - as there are no positive only numbers.
So, the CRC results are wrong.

Any ideas anyone ?

Anybody have a good fast algorithm for CRCs ?

Hope somebody can help.

Moose
0
 
LVL 3

Accepted Solution

by:
sperling earned 100 total points
ID: 1337334
Hope you'll accept this URL as an answer. Got quite a few CRC units.

http://www.pcorner.com/tpc/old/35-101.html

Regards,

Erik.
0
 

Author Comment

by:moose032797
ID: 1337335
Thanks Eric - the link you provided was great.

It took no time at all to take one of these Turbo pascal programs and get it working under Delphi - also improved it as well.

Code works great and is fast !!

Thanks for your help - again !!

Moose
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi Spellcheck in Webbrowser 1 77
SUM 2 INTEGER ARRAYS INTO 1 10 118
Wincontrol not (correctly) drawn 15 59
Broadcast a message using ICS 2 51
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question