/** * Returns the checksum of all but the first 12 bytes of {@code dex}. */ public int computeChecksum(DexBuffer dex) throws IOException { Adler32 adler32 = new Adler32(); int offset = CHECKSUM_OFFSET + CHECKSUM_SIZE; byte[] bytes = dex.getBytes(); adler32.update(bytes, offset, bytes.length - offset); return (int) adler32.getValue(); } /** * Generates the signature and checksum of the dex file {@code out} and * writes them to the file. */ public void writeHashes(DexBuffer dex) throws IOException { byte[] signature = computeSignature(dex); dex.open(SIGNATURE_OFFSET).write(signature);