(File file, MessageDigest hash)
| 379 | } |
| 380 | |
| 381 | public static byte[] hash(File file, MessageDigest hash) throws IOException { |
| 382 | try ( |
| 383 | FileInputStream fis = new FileInputStream(file) |
| 384 | ) { |
| 385 | byte[] buf = new byte[8 * 1024]; |
| 386 | int len; |
| 387 | while ((len = fis.read(buf)) != -1) { |
| 388 | hash.update(buf, 0, len); |
| 389 | } |
| 390 | return hash.digest(); |
| 391 | } |
| 392 | } |
| 393 | |
| 394 | } |