title: Get MD_5 Hash of File in iPhone
body: <p>In my project i need to get the MD_5 hash code of the file in iphone. uptill now i have found the following code to get md_5 of any image/any file.</p>
  
  <pre><code> -(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];
    }
  </code></pre>
  
  <p>using this code to get the ByteContent of the image and then get the md_5 of that image byte array string</p>
  
  <pre><code> UIImage *image = [UIImage imageNamed:@"sf_small.png"];
   NSData *data = UIImagePNGRepresentation(image);
   NSString *str = [NSString stringWithFormat:@"%@",data];
   NSString *temp = [self getMD5FromString:str];
  </code></pre>
  
  <p>now i am getting a hash code succesfully But when on the web side i get the md_5 hash code of same file then it gives me diferent hash code. in Web side i am using PHP code</p>
  
  <pre><code> md5_file(string $filename);
  </code></pre>
  
  <p>this PHP code gives me differnet hash code and iphone code gives me different hash code for same image. Please tell me what can be the problem.. </p>
  
  <p>Thanks alot!</p>
  
  <p><a href="http://i.stack.imgur.com/1xCSA.png" rel="nofollow">tic.png</a></p>