private void writeTrailer() throws IOException { out.write(END_MARK); if (params.withContentChecksum) { ByteUtils.toLittleEndian(out, contentHash.getValue(), 4); } }
private void verifyChecksum(XXHash32 hash, String kind) throws IOException { byte[] checksum = new byte[4]; int read = IOUtils.readFully(in, checksum); count(read); if (4 != read) { throw new IOException("Premature end of stream while reading " + kind + " checksum"); } long expectedHash = hash.getValue(); if (expectedHash != ByteUtils.fromLittleEndian(checksum)) { throw new IOException(kind + " checksum mismatch."); } }
private void writeFrameDescriptor() throws IOException { int flags = FramedLZ4CompressorInputStream.SUPPORTED_VERSION; if (!params.withBlockDependency) { flags |= FramedLZ4CompressorInputStream.BLOCK_INDEPENDENCE_MASK; } if (params.withContentChecksum) { flags |= FramedLZ4CompressorInputStream.CONTENT_CHECKSUM_MASK; } if (params.withBlockChecksum) { flags |= FramedLZ4CompressorInputStream.BLOCK_CHECKSUM_MASK; } out.write(flags); contentHash.update(flags); int bd = (params.blockSize.getIndex() << 4) & FramedLZ4CompressorInputStream.BLOCK_MAX_SIZE_MASK; out.write(bd); contentHash.update(bd); out.write((int) ((contentHash.getValue() >> 8) & 0xff)); contentHash.reset(); }
throw new IOException("Premature end of stream while reading frame header checksum"); int expectedHash = (int) ((contentHash.getValue() >> 8) & 0xff); contentHash.reset(); if (headerHash != expectedHash) {
ByteUtils.toLittleEndian(out, blockHash.getValue(), 4); blockHash.reset();
private void writeTrailer() throws IOException { out.write(END_MARK); if (params.withContentChecksum) { ByteUtils.toLittleEndian(out, contentHash.getValue(), 4); } }
private void verifyChecksum(XXHash32 hash, String kind) throws IOException { byte[] checksum = new byte[4]; int read = IOUtils.readFully(in, checksum); count(read); if (4 != read) { throw new IOException("Premature end of stream while reading " + kind + " checksum"); } long expectedHash = hash.getValue(); if (expectedHash != ByteUtils.fromLittleEndian(checksum)) { throw new IOException(kind + " checksum mismatch."); } }
private void writeFrameDescriptor() throws IOException { int flags = FramedLZ4CompressorInputStream.SUPPORTED_VERSION; if (!params.withBlockDependency) { flags |= FramedLZ4CompressorInputStream.BLOCK_INDEPENDENCE_MASK; } if (params.withContentChecksum) { flags |= FramedLZ4CompressorInputStream.CONTENT_CHECKSUM_MASK; } if (params.withBlockChecksum) { flags |= FramedLZ4CompressorInputStream.BLOCK_CHECKSUM_MASK; } out.write(flags); contentHash.update(flags); int bd = (params.blockSize.getIndex() << 4) & FramedLZ4CompressorInputStream.BLOCK_MAX_SIZE_MASK; out.write(bd); contentHash.update(bd); out.write((int) ((contentHash.getValue() >> 8) & 0xff)); contentHash.reset(); }
throw new IOException("Premature end of stream while reading frame header checksum"); int expectedHash = (int) ((contentHash.getValue() >> 8) & 0xff); contentHash.reset(); if (headerHash != expectedHash) {
ByteUtils.toLittleEndian(out, blockHash.getValue(), 4); blockHash.reset();