473,698 Members | 2,643 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

looking for a complete CRC32 program

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
9 10836
UnixUser <ra*********@pf shouston.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
grobbeltje <gr*****@hotmai l.com> wrote in message news:<br******* ***@news.tue.nl >...
UnixUser <ra*********@pf shouston.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
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
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********@yah oo.com) (cb********@wor ldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net> USE worldnet address!
Nov 14 '05 #5
UnixUser <ra*********@pf shouston.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
ra*********@pfs houston.com (UnixUser) wrote in message news:<a1******* *************** **@posting.goog le.com>...
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;typ edef 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
"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
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
In article <a1************ **************@ posting.google. com>,
ra*********@pfs houston.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
4350
by: Ricky Romaya | last post by:
Hi, I'm working on a file upload script. I need to calculate the CRC32 of the file(s) which are successfully uploaded. How can I do this? PHP only have CRC32 function for strings. However, the uploaded file(s) are mostly binaries, and assumed have large size (5-12 MB per file). Are there any ways other than CRC32 (which supported by default PHP installation) to generate a unique hash of an arbitrary files? (the users of my script are...
1
10025
by: PaullyB | last post by:
Hi, I am attempting to convert the following code written in c to equivalent java code. This is the CRC32 algorithm used by a GPS received I am interfacing with. Unfortunately, the CRC32 class provided in the java API does not suit my needs because it does not allow manipulation of the polynomial being used. Below is the original c-code followed by my attempt to convert the code to java. Unfortunately, my code does not produce the...
6
5827
by: Weiguang Shi | last post by:
Hi there, I'm thinking of using binascii.crc32 as a hash-function when I read in the reference http://www.python.org/doc/current/lib/module-binascii.html: crc32( data) Compute CRC-32, the 32-bit checksum of data, starting with an initial crc. This is consistent with the ZIP file checksum.
14
8776
by: Don | last post by:
Hi NG. Does anyone know of a place where I could download/get a C implementation of a CRC32 check. I would like a simple function that, for example, had a pointer to where the data to be CRC32 calculated reside, an indication of the length of the data and perhaps the polynomium as input arguments and then would return the calculated crc32 value like e.g. an unsigned long. Don
3
3314
by: Russell Mangel | last post by:
Hi, I would like to encapsulate the following CRC32 routine inside a C++ un-mananged class. I am having difficulty initializing the "const static unsigned int table" inside an un-managed C++ class. I would like the lookup table to remain static so it is loaded only once on program startup. I do not want to create the lookup table using a loop, if possible
6
4388
by: Paul M. | last post by:
Hello, does anyone have either a User Function Library (or the source for one) to create a CRC32 checksum for a given string? I want to use the function in a crystal formula thus: formula = CRC32("123456789") This would then display on the report the CRC32 checksum for "123456789".
12
9853
by: Larry Bates | last post by:
I'm trying to get the results of binascii.crc32 to match the results of another utility that produces 32 bit unsigned CRCs. binascii.crc32 returns results in the range of -2**31-1 and 2**21-1. Has anyone ever worked out any "bit twiddling" code to get a proper unsigned 32 bit result from binascii.crc32? Output snip from test on three files: binascii.crc32=-1412119273, oldcrc32= 2221277246
2
3941
by: tlsk | last post by:
Hi I need to calculate the crc32 value for an unsigned array in C++.It goes like this.. unsigned char Myarray; //Myarray contains hex value ... b525b4d0ad533acee2d6a214453a279e Need to calculate the crc32 value for this Myarray. ------------------------------------------------------------------------------------------
0
8683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8611
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8876
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7741
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6531
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5867
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4624
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.