title: The MD5 from a local file and the MD5 (eTag) from S3 is not the same
body: <p>I get the MD5 of a local file but it is different than the MD5 (eTag) of the "same" file in Amazon S3. What I would like to achieve is figure out if the lastest files I have in S3 is the same one that I have locally. If I cannot compare MD5, then how should I do it?</p>
  
  <p>Generating MD5 from the local file (truncated code):</p>
  
  <pre><code>MessageDigest md = MessageDigest.getInstance("MD5");
  byte[] md5 = Files.getDigest(localFile, md);
  String hashtext = DigestUtils.md5Hex(md5);
  </code></pre>
  
  <p>Retrieving MD5 (eTag) from S3 (truncated code):</p>
  
  <pre><code>ObjectListing objectListing = s3.listObjects(new ListObjectsRequest().withBucketName(bucketName));
  List&lt;S3ObjectSummary&gt; objectSummaries = objectListing.getObjectSummaries();
  for(S3ObjectSummary objectSummary : objectSummaries) {
      String MD5 = objectSummary.getETag();
  }
  </code></pre>
  
  <p>PS: I use <code>org.apache.commons.codec.digest.DigestUtils</code> and <code>com.google.common.io.Files</code> libraries.</p>