I need help with a crc32 function on IOS
From these link
http://stackoverflow.com/questions/4115059/get-crc-checksum-of-an-nsdata-in-objective-c
http://ios-blog.co.uk/tutorials/quick-tips/quick-tip-converting-nsstring-to-nsdata/
I try this code
The result is non corretct
From these link
http://stackoverflow.com/questions/4115059/get-crc-checksum-of-an-nsdata-in-objective-c
http://ios-blog.co.uk/tutorials/quick-tips/quick-tip-converting-nsstring-to-nsdata/
I try this code
B4X:
Dim NativeMe As NativeObject = Me
Log(NativeMe.RunMethod("Crc32_String:", Array ("test")).AsString)
#If OBJC
#import <zlib.h>
- (NSString*) Crc32_String: (NSString*) strdata {
//NSString* strdata = @"1234567890";
NSData* data = [strdata dataUsingEncoding:NSUTF8StringEncoding];
data = [data subdataWithRange:NSMakeRange(0, [data length] - 1)];
unsigned long result = crc32(0, data.bytes, data.length);
NSString *str = [NSString stringWithFormat:@"%qi",result];
return str;
}
#end if
The result is non corretct
Last edited: