static byte [ ] sha1 ( InputStream in ) { try { MessageDigest md = MessageDigest . getInstance ( SHA1_DIGEST ) ; byte [ ] buffer = new byte [ 4096 ] ; int bytes ; while ( ( bytes = in . read ( buffer ) ) > 0 ) { md . update ( buffer , 0 , bytes ) ; } return md . digest ( ) ; } catch ( NoSuchAlgorithmException | IOException e ) { throw new InternalErrorException ( e ) ; } }
Compute SHA - 1 hash value for a given input stream .