@Override public Checksum get() { return new Adler32(); } };
/** * Creates a FastLZ decoder with calculation of checksums as specified. * * @param validateChecksums * If true, the checksum field will be validated against the actual * uncompressed data, and if the checksums do not match, a suitable * {@link DecompressionException} will be thrown. * Note, that in this case decoder will use {@link java.util.zip.Adler32} * as a default checksum calculator. */ public FastLzFrameDecoder(boolean validateChecksums) { this(validateChecksums ? new Adler32() : null); }
/** * Creates a FastLZ encoder with auto detection of compression * level and calculation of checksums as specified. * * @param validateChecksums * If true, the checksum of each block will be calculated and this value * will be added to the header of block. * By default {@link FastLzFrameEncoder} uses {@link java.util.zip.Adler32} * for checksum calculation. */ public FastLzFrameEncoder(boolean validateChecksums) { this(LEVEL_AUTO, validateChecksums ? new Adler32() : null); }
@Override public Checksum get() { return new Adler32(); } };
/** * Creates a FastLZ encoder with auto detection of compression * level and calculation of checksums as specified. * * @param validateChecksums * If true, the checksum of each block will be calculated and this value * will be added to the header of block. * By default {@link FastLzFrameEncoder} uses {@link java.util.zip.Adler32} * for checksum calculation. */ public FastLzFrameEncoder(boolean validateChecksums) { this(LEVEL_AUTO, validateChecksums ? new Adler32() : null); }
/** * Creates a FastLZ decoder with calculation of checksums as specified. * * @param validateChecksums * If true, the checksum field will be validated against the actual * uncompressed data, and if the checksums do not match, a suitable * {@link DecompressionException} will be thrown. * Note, that in this case decoder will use {@link java.util.zip.Adler32} * as a default checksum calculator. */ public FastLzFrameDecoder(boolean validateChecksums) { this(validateChecksums ? new Adler32() : null); }
/** * creates a checksum algorithm to be used * @return the checksum used for this txnlog */ protected Checksum makeChecksumAlgorithm(){ return new Adler32(); }
/** * create a checksum algorithm * @return the checksum algorithm */ protected Checksum makeChecksumAlgorithm(){ return new Adler32(); }
@Override public Checksum get() { return new Adler32(); } };
@Override public Checksum get() { return new Adler32(); } };
/** * Creates a FastLZ encoder with auto detection of compression * level and calculation of checksums as specified. * * @param validateChecksums * If true, the checksum of each block will be calculated and this value * will be added to the header of block. * By default {@link FastLzFrameEncoder} uses {@link java.util.zip.Adler32} * for checksum calculation. */ public FastLzFrameEncoder(boolean validateChecksums) { this(LEVEL_AUTO, validateChecksums ? new Adler32() : null); }
/** * Creates a FastLZ decoder with calculation of checksums as specified. * * @param validateChecksums * If true, the checksum field will be validated against the actual * uncompressed data, and if the checksums do not match, a suitable * {@link DecompressionException} will be thrown. * Note, that in this case decoder will use {@link java.util.zip.Adler32} * as a default checksum calculator. */ public FastLzFrameDecoder(boolean validateChecksums) { this(validateChecksums ? new Adler32() : null); }
public long computeCrc() throws IOException { byte[] buffer = new byte[BUFFER_SIZE]; Checksum checksum = new Adler32(); for (File file : _files) { try (InputStream input = new FileInputStream(file)) { int len; while ((len = input.read(buffer)) > 0) { checksum.update(buffer, 0, len); } } } return checksum.getValue(); }
/** * Returns the checksum of all but the first 12 bytes of {@code dex}. */ public int computeChecksum() throws IOException { Adler32 adler32 = new Adler32(); byte[] buffer = new byte[8192]; ByteBuffer data = this.data.duplicate(); // positioned ByteBuffers aren't thread safe data.limit(data.capacity()); data.position(CHECKSUM_OFFSET + SizeOf.CHECKSUM); while (data.hasRemaining()) { int count = Math.min(buffer.length, data.remaining()); data.get(buffer, 0, count); adler32.update(buffer, 0, count); } return (int) adler32.getValue(); }
/** Initialize the checksum interface. */ public void initChecksum() { if (checksum != null) { return; } if ("CRC".equals(algorithm)) { checksum = new CRC32(); } else if ("ADLER".equals(algorithm)) { checksum = new Adler32(); } else { throw new BuildException(new NoSuchAlgorithmException()); } }
public static void updateChecksum(ByteBuffer buffer, int size) { byte[] data = buffer.array(); MessageDigest digest; try { digest = MessageDigest.getInstance("SHA-1"); } catch (NoSuchAlgorithmException e) { throw new AssertionError(); } digest.update(data, 32, size - 32); byte[] sha1 = digest.digest(); System.arraycopy(sha1, 0, data, 12, sha1.length); Adler32 adler32 = new Adler32(); adler32.update(data, 12, size - 12); int v = (int) adler32.getValue(); buffer.position(8); buffer.putInt(v); }
public static long getChecksum(String test) { try { byte buffer[] = test.getBytes(); ByteArrayInputStream bais = new ByteArrayInputStream(buffer); CheckedInputStream cis = new CheckedInputStream(bais, new Adler32()); byte readBuffer[] = new byte[buffer.length]; cis.read(readBuffer); return cis.getChecksum().getValue(); } catch (IOException e) { throw new RuntimeException(e); } }
public void run(String snapshotFileName, boolean dumpData, boolean dumpJson) throws IOException { File snapshotFile = new File(snapshotFileName); try (InputStream is = new CheckedInputStream( new BufferedInputStream(new FileInputStream(snapshotFileName)), new Adler32())) { InputArchive ia = BinaryInputArchive.getArchive(is); FileSnap fileSnap = new FileSnap(null); DataTree dataTree = new DataTree(); Map<Long, Integer> sessions = new HashMap<Long, Integer>(); fileSnap.deserialize(dataTree, sessions, ia); long fileNameZxid = Util.getZxidFromName(snapshotFile.getName(), SNAPSHOT_FILE_PREFIX); if (dumpJson) { printSnapshotJson(dataTree); } else { printDetails(dataTree, sessions, dumpData, fileNameZxid); } } }
private void updateChecksum(@Nonnull DexDataStore dataStore) throws IOException { Adler32 a32 = new Adler32(); byte[] buffer = new byte[4 * 1024]; InputStream input = dataStore.readAt(HeaderItem.CHECKSUM_DATA_START_OFFSET); int bytesRead = input.read(buffer); while (bytesRead >= 0) { a32.update(buffer, 0, bytesRead); bytesRead = input.read(buffer); } // write checksum, utilizing logic in DexWriter to write the integer value properly OutputStream output = dataStore.outputAt(HeaderItem.CHECKSUM_OFFSET); DexDataWriter.writeInt(output, (int)a32.getValue()); output.close(); }
@Parameterized.Parameters(name = "{0}") public static Collection alignments() { return Arrays.asList(new Object[][]{ {new Adler32()}, {new FNV32()}, {new FNV64()}, {new Murmur3A()}, {new Murmur3F()}}); } }