In my project, I need to get the hash code of the MD_5 file in iphone. uptill now i found the following code to get md_5 of any image / any file.
-(NSString *)getMD5FromString:(NSString *)source{ const char *src = [source UTF8String]; unsigned char result[CC_MD5_DIGEST_LENGTH]; CC_MD5(src, strlen(src), result); return [[NSString stringWithFormat: @"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", result[0], result[1], result[2], result[3], result[4], result[5], result[6], result[7], result[8], result[9], result[10], result[11], result[12], result[13], result[14], result[15] ]lowercaseString]; }
using this code to get the ByteContent of the image, and then get the md_5 of this row of byte array of images
UIImage *image = [UIImage imageNamed:@"sf_small.png"]; NSData *data = UIImagePNGRepresentation(image); NSString *str = [NSString stringWithFormat:@"%@",data]; NSString *temp = [self getMD5FromString:str];
now i get the hash code successfully. But when on the webpage I get the md_5 hash of the same file, then it gives me a great hash code. in the web part i'm using php code
md5_file(string $filename);
this php code gives me a differnet hash code and the iphone code gives me different hash codes for the same image. Please tell me what could be the problem.
Thanks a lot!
tic.png
source share