Posts: 1,407
Threads: 117
Joined: Dec 2002
Zire:
If you are adding a CRC algorithm to a "standalone" program, any of the algorithms posted can suit you.
If you are trying to match someone else's CRC, you may have some problems, as there is several ways to do a CRC: you an use different "polynomials", you can use reverse calculation, a constant may be added at the end of calc.... . This tutorial from Bob Stout C snippets explains it all:
http://c.snippets.org/snip_lister.php?fname=crc.txt
Antoni
Posts: 3,522
Threads: 189
Joined: Dec 2003
Antonio, It's for a standalone, so the algos already psted are good.
Moneo, Hmm, the shell/batch file approach would be too slow and memory consuming =(.
Posts: 1,439
Threads: 15
Joined: Apr 2003
Plus, you'd need PKZIP, which is copyrighted software ... although I have the real thing... I think version 2... on a diskette at home. Retro! Goes well with QB.
@antoni: very thorough reference! It looks as if all the major CRC32 implementations are the same, too, which is a Good Thing.
Posts: 1,956
Threads: 65
Joined: Jun 2003
Quote:....Moneo, Hmm, the shell/batch file approach would be too slow and memory consuming =(.
Zire,
With today's fast machines, speed problems are mostly a thing of the past. Unless your target file is 100MB or larger, you will not notice the difference. Plus, the suggested program which does the shell, only does it once.
Also, how many times a day are you going to require this CRC generator? Let's say you need it 10 times a day (which I doubt), then finding a faster approach which saves you 5 seconds per run will save you 50 seconds a day, wow!
If you only need it once in a while, run the batchfile by hand and retrieve the CRC from the temp file with notepad, or type the temp file to the screen.
*****
Posts: 1,752
Threads: 21
Joined: Jun 2002
He said he was going to use it for the filesystem for his fake OS, so he's probably going to CRC every file that's accessed. My guess is that he needs all the speed he can get...
Posts: 6,419
Threads: 74
Joined: Mar 2002
Plus using external executables is a security hole as big as a cathedral.
Posts: 3,522
Threads: 189
Joined: Dec 2003
Quote:He said he was going to use it for the filesystem for his fake OS, so he's probably going to CRC every file that's accessed. My guess is that he needs all the speed he can get...
Quote:Plus using external executables is a security hole as big as a cathedral.
Nice, I didn't even have to answer =)
I will calculate the CRC at start and shutdown of Novix, for each file in NVXFS. So speed is an issue, one second extra per file means one extra second's delay at boot and shutdown.
Security problems, sure, not that Novix is going to be used for anything serious (I doubt it)
But I like to use "my own" code, as it gives more freedom then using the shell approach.
Not to mention that I would have to detect if the user was running WinXP and add CMD to the shell to make it work, blarg!
Posts: 1,956
Threads: 65
Joined: Jun 2003
Ok, ok, I was just suggesting some simple, quick and dirty ways to get a CRC.
There's still the CRC generator program that I wrote in "C", which I already mention to you. It's fast (uses the table method), and the resultant CRC-32 is the same as Pkzip, which makes it very easy to check out. Are you interested in this code?
NATHAN, regarding your comment of "Plus using external executables is a security hole as big as a cathedral". That's only true if your external executabes have not been duly approved by your security administration. Can you imagine any system in today's Internet/Intranet environments that could only use internally developed executables, or only being able to use executables for software developed by Microsoft? What about Oracle, Adobe, McAfee, Norton, WinZip, Java, etc. Would you classify these as "security violating external executables"?
*****
Posts: 6,419
Threads: 74
Joined: Mar 2002
Nope, 'cause they use certificates and sessions to communicate. But still, there's a big security hole: see how easy is to infect a Windows system.
Imagine that you use PKZIP/PKUNZIP to calculate/check the CRC. Someone can rename his VIRUS.EXE to PKZIP.EXE and do whatever he or she wants. When you have to rely in an external executable for a task 'cause you can't do it otherwise, okay, but if you can avoid it, go ahead.
Posts: 1,956
Threads: 65
Joined: Jun 2003
Quote:Nope, 'cause they use certificates and sessions to communicate. But still, there's a big security hole: see how easy is to infect a Windows system.
Imagine that you use PKZIP/PKUNZIP to calculate/check the CRC. Someone can rename his VIRUS.EXE to PKZIP.EXE and do whatever he or she wants. When you have to rely in an external executable for a task 'cause you can't do it otherwise, okay, but if you can avoid it, go ahead.
Nathan,
I'm not familiar with the terms "certificates and sessions", but I assume you mean programs that are officially installed in Windows using the Control Panel/Add or Remove Programs method which I understand makes them part of the Registry.
If this method protects programs from being changed or renamed, then I get what you mean, and you're right. Thanks.
*****
|