public static byte[] digest(InputStream data,MessageDigest messageDigest) throws GeneralSecurityException, IOException {
  byte[] buf=new byte[8192];
  int n;
  while ((n=data.read(buf)) > 0) {
    messageDigest.update(buf,0,n);
  }
  return messageDigest.digest();
}

public static byte [ ] digest ( InputStream data , MessageDigest messageDigest ) throws GeneralSecurityException , IOException { byte [ ] buf = new byte [ 8192 ] ; int n ; while ( ( n = data . read ( buf ) ) > 0 ) { messageDigest . update ( buf , 0 , n ) ; } return messageDigest . digest ( ) ; }
create a digest based on the inputstream .
