private static String calcFileMd5(String path) {
        byte[] buffer = new byte[DOWNLOAD_PACKAGE_READ_BUFF_SIZE];
        int len = 0;
        String ret = null;
        try (FileInputStream fileInputStream = new FileInputStream(path)) {
            MessageDigest md = MessageDigest.getInstance("MD5");
            while ((len = fileInputStream.read(buffer)) != -1) {
                md.update(buffer, 0, len);
            }
            ret = new String(Hex.encodeHex(md.digest()));
        } catch (NoSuchAlgorithmException e) {
            LOGGER.error("calc file md5 NoSuchAlgorithmException", e);
        } catch (IOException e) {
            LOGGER.error("calc file md5 IOException", e);
        }
        return ret;
    }
It should guarantee thread-safe, and can be invoked many times.

@throws Exception exceptions
inlong-agent/agent-installer/src/main/java/org/apache/inlong/agent/installer/ModuleManager.java