title: md5 hash from picture differs in iOS / Android
body: <p>I have a question about the md5 hash from an image. I have already written an android app which generates the md5 hash from every image it takes and saves the image under this filename. When I compare the string with a program on my Windows PC it is exact the same string. Even online generators generate the same string. So I think everything works fine on Android.
  Now it comes to iOS... I don't know what and how, but iOS7 changes every Image it gets. (I think).
  For example:
  If I make a photo, generate the hash from this picture and save it on my Android or Desktop it has an other hash then it had on the iPhone.
  I even tried to save one of my images through safari on my iPhone and then sendet it back to my desktop. Tada, I got another hash then before. Even the size of the picture is different (about 300b).</p>
  
  <p>Can someone tell me what Apple is doing here and how to avoid this? How can I compare images downloaded from a server on an android and iOS device if the hash will never be the same?</p>
  
  <p>I'm using the hash to compare if the picture was correctly downloaded from my server, but under this circumstances it doesn't work under iOS.</p>
  
  <p>I have read a similar article here: <a href="https://stackoverflow.com/questions/24562540/ios-uiimage-data-differ-with-android-image-for-image-downloaded-from-google">IOS UIImage data differ with android image (for image downloaded from google)</a>
  But there was no direct answer to this. I believe that the md5 Method from iOS works correct, but I think iOS does "things" with images so that the md5 is always different.</p>
  
  <p>Thank you.</p>
  
  <p>edit:
  here is my code for generating a hash:</p>
  
  <pre><code>+(NSString*)getHash:(UIImage *)bild{
      NSData *imageData = UIImagePNGRepresentation(bild);
      unsigned char md5Buffer[CC_MD5_DIGEST_LENGTH];
  
      CC_MD5(imageData.bytes, imageData.length, md5Buffer);
  
      NSMutableString *output = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
      for(int i = 0; i &lt; CC_MD5_DIGEST_LENGTH; i++)
          [output appendFormat:@"%02x",md5Buffer[i]];
  
      NSLog(@"Result: %@",output);
      return output;
  }
  </code></pre>