title: How does SDK or ADT generate SHA1-Digest for Resources of Android application packages
body: <p>In a signed apk, there would be a <em>META-INF/MANIFEST.MF</em> file. And in this file, we can find the digests like these:</p>
  
  <blockquote>
    <p>Name: res/layout/main.xml SHA1-Digest: NJ1YLN3mBEKTPibVXbFO8eRCAr8=</p>
    
    <p>Name: AndroidManifest.xml SHA1-Digest: BlnC6ZBDtQYWeJNiespsQve82wY=</p>
    
    <p>Name: res/drawable-mdpi/ic_launcher.png SHA1-Digest:
    4ss2KZ3FzkmfE6HAAsVu0aJKx1U=</p>
  </blockquote>
  
  <p>I've found a way to generate digest in java like this:</p>
  
  <pre><code>public static void main(String[] args) throws NoSuchAlgorithmException, Exception {
      MessageDigest md = MessageDigest.getInstance("sha-1");
      FileInputStream in =  new FileInputStream("./ic_launcher.png");
      int bytes = 0;
      while ((bytes = in.read()) != -1) {
          md.update((byte)bytes);
      }
      in.close();
      byte[] thedigest = md.digest();
      System.out.println(Base64Encoder.encode(thedigest));
  }
  </code></pre>
  
  <p>For testing , I've used this simple code to generate some digests, which are mostly the same as digests of <em>META-INF/MANIFEST.MF</em> in apk, and still have a small number of exceptions. Like this Png file:<img src="https://i.stack.imgur.com/cVV1n.png" alt="enter image description here"> </p>
  
  <p>In apk the digest for this png file is <em>4ss2KZ3FzkmfE6HAAsVu0aJKx1U=</em> , which is very different from <em>sjmKOs4BYDXg7COdeTc8tIfPBR0=</em> generated by my code above.</p>
  
  <p>But how to explain that there're almost 20 digests generated by my code is the same as the digests in the apk, and Only this Png's digest is different?</p>
  
  <p>Could you please tell me how SDK or ADT generates SHA1-Digest for Resources of Android application packages,  or the differences from my code? </p>
  
  <p>Many thanks!</p>