question: String generateDigest ( File fileDir , String fileName ) { final String algorithm = "SHA-1" ; InputStream fileStream = null ; DigestInputStream d = null ; try { fileStream = getFileStream ( fileDir , fileName ) ; MessageDigest md = MessageDigest . getInstance ( algorithm ) ; d = new DigestInputStream ( fileStream , md ) ; byte [ ] buffer = new byte [ 8196 ] ; while ( d . read ( buffer ) != - 1 ) { } return toHexString ( md . digest ( ) ) ; } catch ( NoSuchAlgorithmException e ) { return algorithm + " not found" ; } catch ( IOException e ) { CLog . e ( e ) ; } finally { StreamUtil . closeStream ( d ) ; StreamUtil . closeStream ( fileStream ) ; } return "failed to generate digest" ; }
target:  Generate a sha1sum digest for a file. <p/> Exposed for unit testing.