/** * Computes the hash of given stream. The stream is closed by this method. */ public String of(InputStream input) { try(InputStream is = input) { MessageDigest digest = MessageDigest.getInstance("MD5"); byte[] hash = digest(is, digest); return toHex(hash); } catch (Exception e) { throw new IllegalStateException("Fail to compute hash", e); } }