title: checksum is same for different images
body: <p>I am sending thousands of images from one system to another over FTP. Initially, I'll dump all the images, but later on, I want to send only those images which are changed.</p>
  
  <p>I haven't found any concrete solution to figure out changed images based on the updated timestamp in windows. Therefore, I decided the following approach: </p>
  
  <p>1.) Generate checksums for all the files and store them somewhere. Maybe database or filesystem.</p>
  
  <p>2.) Every time I send files to another system, compare the checksums and send only the files which have different checksums.</p>
  
  <p>In order to test the above, I tried to generate a checksum (SHA and MD5) for two different images, and the checksum was the same.</p>
  
  <p>Following is the sample code: </p>
  
  <pre><code>package com.test;
  
  import java.io.FileInputStream;
  import java.io.IOException;
  
  import org.apache.commons.codec.digest.DigestUtils;
  
  public class TestHash {
       public static void main(String[] args) throws IOException {
  
              String checksumSHA256 = DigestUtils.sha256Hex(new FileInputStream("monkey_11.jpg"));
              System.out.println("checksumSHA256 : " + checksumSHA256);
  
              String checksumMD5 = DigestUtils.md5Hex(new FileInputStream("monkey_11.jpg"));
              System.out.println("checksumMD5 : " + checksumMD5);
  
  
              String checksumSHA256_1 = DigestUtils.sha256Hex(new FileInputStream("monkey.jpg"));
              System.out.println("checksumSHA256 : " + checksumSHA256_1);
  
              String checksumMD5_1 = DigestUtils.md5Hex(new FileInputStream("monkey.jpg"));
              System.out.println("checksumMD5 : " + checksumMD5_1);
  
          }
  }
  </code></pre>
  
  <p>I'm wondering why the checksums are the same? Is there another way to identify updated images?</p>