title: md5 file checksum from specific bytes
body: <p>I want to create a md5 checksum from specific bytes from file.
  checksum will be from 100 bytes from file.</p>
  
  <p>I write this code:</p>
  
  <pre><code>public static String getMD5ChecksumByFlash(String filename) throws Exception {
      InputStream fis = new FileInputStream(filename);
      byte[] buffer = new byte[1];
      MessageDigest complete = MessageDigest.getInstance("MD5");
  
      int passes = fis.available() / 100;
      int currentOffset = 0;
      int readBytes = -1;
  
      do {
          System.out.println("0a "+currentOffset);
          System.out.println("0b "+readBytes);
          readBytes = fis.read(buffer, currentOffset, 1);
          System.out.println("1 "+currentOffset);
          System.out.println("2 "+readBytes);
          if ( readBytes!=-1 ) {
              complete.update(buffer, 0, readBytes);
              currentOffset += passes;
              System.out.println("4 "+readBytes);
          }
          System.out.println("3 "+currentOffset);
          System.out.println("5 "+readBytes);
      } while ( readBytes!=-1 );
      fis.close();
  
      byte[] b = complete.digest();
      String result = "";
      for (int i = 0; i &lt; b.length; i++) {
          result += Integer.toString((b[i] &amp; 0xff) + 0x100, 16).substring(1);
      }
      return result;
  }
  </code></pre>
  
  <p>but it doesn't work :/
  It returns:</p>
  
  <pre><code>0a 0
  0b -1
  1 0
  2 1
  4 1
  3 93928
  5 1
  0a 93928
  0b 1
  null
  </code></pre>
  
  <p>What's wrong?</p>
  
  <p>PS.
  This file isn't 1byte file - it's pidgin-2.10.1.exe</p>