code: @Override
      public Collection<FixityResult> checkFixity(final String algorithm) {
  
          try (FixityInputStream fixityInputStream = new FixityInputStream(
                  this.getInputStream(), MessageDigest.getInstance(algorithm))) {
  
              // actually calculate the digest by consuming the stream
              while (fixityInputStream.read(devNull) != -1) { }
  
              final URI calculatedChecksum =
                      ContentDigest.asURI(algorithm, fixityInputStream.getMessageDigest().digest());
  
              final FixityResult result =
                  new FixityResultImpl(getExternalIdentifier(),
                                      fixityInputStream.getByteCount(),
                                      calculatedChecksum,
                                      algorithm);
  
              return singletonList(result);
          } catch (final IOException e) {
              LOGGER.debug("Got error closing input stream: {}", e);
              throw new RepositoryRuntimeException(e);
          } catch (final NoSuchAlgorithmException e1) {
              throw new RepositoryRuntimeException(e1);
          }
      }
docs: Calculate the fixity of a CacheEntry by piping it through
  a simple fixity-calculating InputStream
  
  @param algorithm the digest algorithm to be used
  @return the fixity of this cache entry