Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective-C Implicit conversion loses integer precision (size_t to CC_Long)

Tags:

I have a function that's generating a sha256 encryption of a string,

Here's the function:

    -(NSString*)sha256HashFor:(NSString*)input {     const char* str = [input UTF8String];     unsigned char result[CC_SHA256_DIGEST_LENGTH];     CC_SHA256(str, strlen(str), result);      NSMutableString *ret = [NSMutableString stringWithCapacity:CC_SHA256_DIGEST_LENGTH*2];     for(int i = 0; i<CC_SHA256_DIGEST_LENGTH; i++)     {         [ret appendFormat:@"%02x",result[i]];     }     return ret; } 

Now this line right here CC_SHA256(str, strlen(str), result); is what's producing this warning (the warning is for the strlen(str) variable).

Implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'CC_LONG' (aka 'unsigned int') 

I'm guessing I just need to convert the strlen(str) to a CC_Long, but I have no idea how to do that.