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

后端 未结 3 611
野趣味
野趣味 2021-02-12 08:11

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

Here\'s the function:

    -(NSString*)sha256HashFor:(NSString*)input
{
    const ch         


        
3条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-12 08:49

    This code will not show any warning and works perfectly.

    - (NSString*) sha256 {
        const char * pointer = [self UTF8String];
        unsigned char result[CC_SHA256_DIGEST_LENGTH];
        CC_SHA256(pointer, (CC_LONG)strlen(pointer), result);
    
        NSMutableString *ret = [NSMutableString stringWithCapacity:CC_SHA256_DIGEST_LENGTH*2];
        for(int i = 0; i

提交回复
热议问题