Esempio n. 1
0
  public static String getChecksum(Path filePath) throws IOException {
    if (!isValidChecksum(filePath)) {
      return "";
    }

    InputStream fileInputStream = null;

    try {
      fileInputStream = Files.newInputStream(filePath);

      byte[] bytes = DigestUtils.sha1(fileInputStream);

      return Base64.encodeBase64String(bytes);
    } finally {
      StreamUtil.cleanUp(fileInputStream);
    }
  }
Esempio n. 2
0
  public static String getChecksum(Path filePath) throws IOException {
    if (!Files.exists(filePath)
        || (Files.size(filePath) > PropsValues.SYNC_FILE_CHECKSUM_THRESHOLD_SIZE)) {

      return "";
    }

    InputStream fileInputStream = null;

    try {
      fileInputStream = Files.newInputStream(filePath);

      byte[] bytes = DigestUtils.sha1(fileInputStream);

      return Base64.encodeBase64String(bytes);
    } finally {
      StreamUtil.cleanUp(fileInputStream);
    }
  }