MCPcopy Create free account
hub / github.com/CodingGay/BlackDex / CalculateChecksum

Method CalculateChecksum

Bcore/src/main/cpp/dex/compact_dex_file.cc:65–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63
64
65uint32_t CompactDexFile::CalculateChecksum(const uint8_t* base_begin,
66 size_t base_size,
67 const uint8_t* data_begin,
68 size_t data_size) {
69 Header temp_header(*Header::At(base_begin));
70 // Zero out fields that are not included in the sum.
71 temp_header.checksum_ = 0u;
72 temp_header.data_off_ = 0u;
73 temp_header.data_size_ = 0u;
74 uint32_t checksum = ChecksumMemoryRange(reinterpret_cast<const uint8_t*>(&temp_header),
75 sizeof(temp_header));
76 // Exclude the header since we already computed it's checksum.
77 checksum = (checksum * 31) ^ ChecksumMemoryRange(base_begin + sizeof(temp_header),
78 base_size - sizeof(temp_header));
79 checksum = (checksum * 31) ^ ChecksumMemoryRange(data_begin, data_size);
80 return checksum;
81}
82
83uint32_t CompactDexFile::CalculateChecksum() const {
84 return CalculateChecksum(Begin(), Size(), DataBegin(), DataSize());

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected