How can I count CRC (32 or 64) of an NSData object in Objective-C?
Thanks in advance!
Use crc32()
function from zlib
library:
#import <zlib.h>
NSData *data;
// ...
unsigned long result = crc32(0, data.bytes, data.length);
NSLog(@"CRC32: %lu", result);
Make sure to link libz
library with your project:
From iOS11 use this:
unsigned long result = crc32_z(0, data.bytes, data.length);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With