(InputStream is, String algorithm)
| 3277 | } |
| 3278 | |
| 3279 | static String getHash(InputStream is, String algorithm) throws NoSuchAlgorithmException, IOException { |
| 3280 | MessageDigest digest = MessageDigest.getInstance(algorithm); |
| 3281 | |
| 3282 | int count; |
| 3283 | byte[] buffer = new byte[BUFFER_SIZE]; |
| 3284 | while ((count = is.read(buffer)) != -1) |
| 3285 | digest.update(buffer, 0, count); |
| 3286 | |
| 3287 | return hex(digest.digest()); |
| 3288 | } |
| 3289 | |
| 3290 | static String hex(byte[] bytes) { |
| 3291 | StringBuilder sb = new StringBuilder(); |