/** * 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); int checksum = computeChecksum(dex); dex.open(CHECKSUM_OFFSET).writeInt(checksum); } }
private DexBuffer mergeDexBuffers() throws IOException { mergeStringIds(); mergeTypeIds(); mergeTypeLists(); mergeProtoIds(); mergeFieldIds(); mergeMethodIds(); mergeAnnotations(); unionAnnotationSetsAndDirectories(); mergeClassDefs(); // write the header contentsOut.header.off = 0; contentsOut.header.size = 1; contentsOut.fileSize = dexOut.getLength(); contentsOut.computeSizesFromOffsets(); contentsOut.writeHeader(headerOut); contentsOut.writeMap(mapListOut); // generate and write the hashes new DexHasher().writeHashes(dexOut); return dexOut; }