• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: looking for a crc code
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: looking for a crc code


  • Subject: Re: looking for a crc code
  • From: Michael Hall <email@hidden>
  • Date: Sat, 14 Jun 2008 12:49:45 -0500


On Jun 14, 2008, at 10:25 AM, Jens Alfke wrote:


On 14 Jun '08, at 4:59 AM, Ilan Volow wrote:

No mention at all I can find (in the 20 seconds I scanned the first two result pages) of any cocoa CRC implementations. If a newbie were to do a search like this and turned up such a fruitless list of leads, I wouldn't be surprised in the least that they came to the list and asking for a personal recommendation of some hard-to-find Cocoa framework from experienced Cocoa programmers.

Yes, but what does CRC have to do with Cocoa? It's just a function that takes a pointer and a length and returns an int. It'd be trivial to use any C implementation in a Cocoa app, so there's no reason to restrict the search by adding "cocoa" as a keyword.

I googled up this one. Might of taken more than a minute I'm afraid. Checksum, Please http://yamacdev.blogspot.com/2006/12/checksum-please.html

It suggests zlib which should always be available, shouldn't it?

#import <Cocoa/Cocoa.h>
# include <sys/types.h>
#include <zlib.h>

int main(int argc, const char * argv[]) {
     NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

     unsigned long crc = crc32(0L, Z_NULL, 0);
     char * test = "TEST";

     crc = crc32(crc,test,4);
	 fprintf(stdout,"crc=%i\n",crc);
}

compiled with...
gcc -framework Cocoa -lz -o testcrc testcrc.m
(Note the -lz for zlib also find some copy of zlib.h for more info on the crc32() method or a adler or other zlib supported alternative)


Unfortunately, testing got sort of inconsistent results.
./testcrc
crc=-286616648

doesn't seem to work out quite the same as...
crc32 test.txt
f783d7be
(man crc32, it appears to be the tcl version mentioned in the blog above.).


The crc's as far as I know should be the same here, so not quite sure what the deal is there, but zlib crc's I think should always be available.

Mike Hall        hallmike at att dot net
http://www.geocities.com/mik3hall
http://sourceforge.net/projects/macnative



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: looking for a crc code
      • From: Chris Suter <email@hidden>
    • Re: looking for a crc code
      • From: Tommy Nordgren <email@hidden>
    • Re: looking for a crc code
      • From: Andrew Farmer <email@hidden>
References: 
 >looking for a crc code (From: Angelo Chen <email@hidden>)
 >Re: looking for a crc code (From: Graham Cox <email@hidden>)
 >Re: looking for a crc code (From: Ilan Volow <email@hidden>)
 >Re: looking for a crc code (From: Jens Alfke <email@hidden>)

  • Prev by Date: Saving Bindings and Editing Font
  • Next by Date: Re: CoreAnimation removeFromSuperlayer flicker
  • Previous by thread: Re: looking for a crc code
  • Next by thread: Re: looking for a crc code
  • Index(es):
    • Date
    • Thread