public static String sha1 ( final InputStream inputStream ) throws IOException , NoSuchAlgorithmException { MessageDigest md = MessageDigest . getInstance ( "SHA-1" ) ; byte [ ] bytes = new byte [ 8192 ] ; int byteCount ; while ( ( byteCount = inputStream . read ( bytes ) ) > 0 ) { md . update ( bytes , 0 , byteCount ) ; } inputStream . close ( ) ; return new String ( encodeHex ( md . digest ( ) ) ) ; }
Utilitiy method to calculate sha1 based on given inputStream .