(@NonNull InputStream is)
| 164 | } |
| 165 | |
| 166 | @NonNull |
| 167 | public static byte[] calculateFileMd5(@NonNull InputStream is) throws IOException { |
| 168 | Objects.requireNonNull(is, "is == null"); |
| 169 | try (is) { |
| 170 | MessageDigest md = MessageDigest.getInstance("MD5"); |
| 171 | byte[] buf = new byte[8192]; |
| 172 | int len; |
| 173 | while ((len = is.read(buf)) != -1) { |
| 174 | md.update(buf, 0, len); |
| 175 | } |
| 176 | return md.digest(); |
| 177 | } catch (NoSuchAlgorithmException e) { |
| 178 | throw new IOException("No MD5 algorithm found", e); |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | @NonNull |
| 183 | public static byte[] calculateFileMd5(@NonNull File file) throws IOException { |
no outgoing calls
no test coverage detected