By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,426 Members | 1,689 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,426 IT Pros & Developers. It's quick & easy.

looking for a complete CRC32 program

P: n/a
I am looking for some source code to run on Linux that will enable me
to calculate and return a CRC32 value from a string of text. I have
found one from snippets.org, but I cannot get it to compile. Please
help me find something that is simple to install, includes all header
and language files and that will compile.
Nov 14 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
UnixUser <ra*********@pfshouston.com> wrote:
I am looking for some source code to run on Linux that will enable me
to calculate and return a CRC32 value from a string of text. I have
found one from snippets.org, but I cannot get it to compile. Please
help me find something that is simple to install, includes all header
and language files and that will compile.


try seraching for "Gary S. Brown" in combination with crc32.
if you have some sources with your linux distro, you probably
already have a few crc32.c's handy though.

anyway, google handed me this site:
http://mia.ece.uic.edu/cgi-bin/lxr/h...=openssh-3.5p1
which seems to work fine for me.

good luck!
grobbeltje.
--
I took a course in speed waiting.
Now I can wait an hour in only ten minutes. -- Steven Wright
Nov 14 '05 #2

P: n/a
grobbeltje <gr*****@hotmail.com> wrote in message news:<br**********@news.tue.nl>...
UnixUser <ra*********@pfshouston.com> wrote:
I am looking for some source code to run on Linux that will enable me
to calculate and return a CRC32 value from a string of text. I have
found one from snippets.org, but I cannot get it to compile. Please
help me find something that is simple to install, includes all header
and language files and that will compile.


try seraching for "Gary S. Brown" in combination with crc32.
if you have some sources with your linux distro, you probably
already have a few crc32.c's handy though.

anyway, google handed me this site:
http://mia.ece.uic.edu/cgi-bin/lxr/h...=openssh-3.5p1
which seems to work fine for me.

good luck!
grobbeltje.


Thanks so much for your reply. This site is to difficult to assemble.
To try to bring the include files and the "c" source file together
will take more time than I have. I downloaded the program and the
crc32.h file, but when I went to bring in the other include file I ran
into much more crap than I can handle. I am not indending on being a
checksum expert I only need a routine as part of a larger project.
Nov 14 '05 #3

P: n/a
Mac
On Wed, 17 Dec 2003 07:48:05 +0000, UnixUser wrote:
I am looking for some source code to run on Linux that will enable me
to calculate and return a CRC32 value from a string of text. I have
found one from snippets.org, but I cannot get it to compile. Please
help me find something that is simple to install, includes all header
and language files and that will compile.


Yeah, that code is full of windows-isms.

You can search and replace DWORD with unsigned long. Then supply a working
macro for UPDC32. I found one by searching on the WWW. Put the macro in
"crc.h"

Then you will have a piece of code that should compile. If, at that point,
you still have problems, post the code here and someone will help you out.
Make sure you post everything needed to try the compilation.

Note that this is not a sources wanted newsgroup, but one for questions about
ISO C.

good luck!

Mac

Nov 14 '05 #4

P: n/a
UnixUser wrote:
.... snip ...
Thanks so much for your reply. This site is to difficult to assemble.
To try to bring the include files and the "c" source file together
will take more time than I have. I downloaded the program and the
crc32.h file, but when I went to bring in the other include file I ran
into much more crap than I can handle. I am not indending on being a
checksum expert I only need a routine as part of a larger project.


Then I suggest you look around here for available programmers who
can handle the problem, and hire one or more of them. You will
have to generate some interface specifications, or require a
consultant for that phase in addition.

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
Nov 14 '05 #5

P: n/a
UnixUser <ra*********@pfshouston.com> wrote:
This site is to difficult to assemble.
To try to bring the include files and the "c" source file together
will take more time than I have.

i'm a beginner at c, and it took me less time to get it
to work than it took to check my spelling for this reply,
so it can't be very hard...

what exactly is going wrong?

greetings, grobbeltje.
--
"e, s, s, s, n, e, e, nw, get chest, se, n, d" - Sound familiar?
Nov 14 '05 #6

P: n/a
ra*********@pfshouston.com (UnixUser) wrote in message news:<a1************************@posting.google.co m>...
I am looking for some source code to run on Linux that will enable me
to calculate and return a CRC32 value from a string of text.


I once wrote this, I don't know if it's quite what you're looking for though :-)

#include <stdio.h>
#include <stdlib.h>

int main(int a,char **A){FILE*B;typedef unsigned long C;C b
[8]; if(!(a==7&&(B= fopen(1[A],"rb")))) return 1;for(7[b]=0
;7[b]<5;7[b]++)b[7[ b]]=strtoul(A[2+7[b ]],0,16-!7[b]*6);5[
b]=3[b] ; while ((6[b]= getc(B)
)!=(C)- 1){if(2 [b])for (7[b]=0
;7[b]<4 ;7[b]++ )if(((6 [b]>>7[
b])^(6[ b]>>(7-7[b])))&1)6[ b] ^=(1
<<7[b]) ^(1<<(7-7[b]));5[b] ^= 6[b]
<<(0[b] -8);for(7[b]=0;7[b] <8;7[b]
++)if(( 5[b]>>(0[b]- 1))&1)5
[b]=(5[ b]<<1)^ 1[b]; else 5[
b]<<=1; }5[b]&=((((C)1 <<(0[b]
-1))-1) <<1)|1; if(2[b] )for(7[
b]=0;7[ b]<(0[b ]>>1);7 [b] ++)
if(((5[b]>>7[b])^(5 [b]>>(0 [b]-1-7 [b])))&1)5[b]^=((C)
1<<7[b])^((C)1<<(0[ b]-1-7[ b]));5[ b]^=4[b];fclose(B);
printf("%0*lX\n", ( int)(0[ b]+3)>> 2,5[b]); return 0;}

For CRC-32, invoke with the following arguments:
filename 32 04C11DB7 1 FFFFFFFF FFFFFFFF

greetings,
Tom
Nov 14 '05 #7

P: n/a
"Mac" <fo*@bar.net> wrote in message news:<pa****************************@bar.net>...
On Wed, 17 Dec 2003 07:48:05 +0000, UnixUser wrote:
I am looking for some source code to run on Linux that will enable me
to calculate and return a CRC32 value from a string of text. I have
found one from snippets.org, but I cannot get it to compile. Please
help me find something that is simple to install, includes all header
and language files and that will compile.


Yeah, that code is full of windows-isms.

You can search and replace DWORD with unsigned long. Then supply a working
macro for UPDC32. I found one by searching on the WWW. Put the macro in
"crc.h"

Then you will have a piece of code that should compile. If, at that point,
you still have problems, post the code here and someone will help you out.
Make sure you post everything needed to try the compilation.

Note that this is not a sources wanted newsgroup, but one for questions about
ISO C.

good luck!

Mac


Thanks for your kind reply. Replacing the macro "UPDC32" is a little
bit over my head at this point in time.
Nov 14 '05 #8

P: n/a
Mac
On Thu, 18 Dec 2003 20:49:36 +0000, UnixUser wrote:
"Mac" <fo*@bar.net> wrote in message news:<pa****************************@bar.net>...
On Wed, 17 Dec 2003 07:48:05 +0000, UnixUser wrote:
> I am looking for some source code to run on Linux that will enable me
> to calculate and return a CRC32 value from a string of text. I have
> found one from snippets.org, but I cannot get it to compile. Please
> help me find something that is simple to install, includes all header
> and language files and that will compile.


Yeah, that code is full of windows-isms.

You can search and replace DWORD with unsigned long. Then supply a working
macro for UPDC32. I found one by searching on the WWW. Put the macro in
"crc.h"

Then you will have a piece of code that should compile. If, at that point,
you still have problems, post the code here and someone will help you out.
Make sure you post everything needed to try the compilation.

Note that this is not a sources wanted newsgroup, but one for questions about
ISO C.

good luck!

Mac


Thanks for your kind reply. Replacing the macro "UPDC32" is a little
bit over my head at this point in time.


Oh, no, you wouldn't be replacing it. What I had in mind was cutting and
pasting a definition from the internet into your own code. One of the
reasons the snippet doesn't compile is that this macro isn't defined
anywhere in the snippet.

For example at this URL:

http://cctr.umkc.edu/ftp/anon_ftp/pub/SRC/ZMODEM/CRC.C

I found this:

#define UPDC32(octet, crc) (crc_32_tab[((crc) ^ (octet)) & 0xff] ^ ((crc) >> 8))

(sorry, it's a long line. If it breaks, reconstruct it manually)

The code seems to obviously be from the snippet code, so I imagine that
the macro definition will work.

Anyway, good luck.

Mac
--

Nov 14 '05 #9

P: n/a
In article <a1**************************@posting.google.com >,
ra*********@pfshouston.com says...
Thanks for your kind reply. Replacing the macro "UPDC32" is a little
bit over my head at this point in time.


Save yourself some time and google for "Hacker's Delight". It's a great
book, but from your own definition above, probably too deep in general
to purchase right now anyway. However, the author has a website, and
there are several different fully implemented CRC implementations
available.

--
Randy Howard _o
2reply remove FOOBAR \<,
______________________()/ ()______________________________________________
SCO Spam-magnet: po********@sco.com
Nov 14 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.