How to check CRC32 NSData?

Possible duplicate:
Get CRC checksum NSData in Objective-C

I can not find the implementation of CRC32 algoryghm in xcode. Can someone help me calculate this?

+6
iphone crc32
source share
1 answer

libz has a crc32() function. To use it with NSData, try this simple category:

Your title:

 @interface NSData (CRC32) - (uint32_t)CRC32Value; @end 

Your implementation:

 #include "your header" #include <zlib.h> @implementation NSData (CRC32) - (uint32_t)CRC32Value { uLong crc = crc32(0L, Z_NULL, 0); crc = crc32(crc, [self bytes], [self length]); return crc; } @end 
+15
source share

All Articles