protected byte[] calculateChecksum(String algorithm) {
    try {
      StringBuilder sb = new StringBuilder();
      for (String filePath : filePaths) {
        File file = new File(filePath);
        sb.append(filePath);
        sb.append(getFileSize(filePath));
        sb.append(file.lastModified());
      }
      MessageDigest messageDigest = MessageDigest.getInstance(algorithm);
      messageDigest.update(Bytes.toBytes(sb.toString()));
      return messageDigest.digest();
    } catch (IOException ioex) {
      LOG.error("Calculating checksum failed, because of ", ioex);
      return new byte[0];
    } catch (NoSuchAlgorithmException e) {
      LOG.error("No such algorithm : " + algorithm + "!");
      return new byte[0];
    }
  }
Using an encryption algorithm to calculate a checksum, the default encryption algorithm is MD5
@return the checksum which is convert to HexString
@throws IOException              something happened like file not exists
@throws NoSuchAlgorithmException no such algorithm
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/PersistentIOEngine.java