Hello,
Here the code "flatted" - executed in main thread.
NSString* pfn = /* path file name */
NSData* data = [NSData dataWithContentsOfFile:pfn];
....
if( data.length > 0 )
{
CC_LONG hashLen = CC_SHA256_DIGEST_LENGTH;
unsigned char hash[ hashLen ];
CC_SHA256( data.bytes, (CC_LONG)data.length, hash );
NSMutableString *output = [NSMutableString stringWithCapacity:hashLen * 2];
for (int i = 0 ; i < hashLen ; i++ )
[output appendFormat:@"%02x", hash[i]];
return output;
}
return nil;
and then, NSString is compared to the required Hash.
What we know with some tests elsewhere :
required hash length > 0
file exists, file have the good size (about 4400 bytes)
data.length > 0
the code above return not nil (output)
but comparaison return not equal for a small part of all devices, and only from iOS17.4