Add streaming support to LZ4 compress routine
In preparation to enable lz4diff streaming mode.
Instead of append data to std::vector, lz4diff APIs
now accept a sink function which we send computed data
to. This way, caller can choose to cache data in memory,
or stream writes to disk as data comes.
Bug: 206729162
Test: th
Change-Id: Ib1aea5c1b730d30a1b4814f8d5dd8ce3a8b43826
diff --git a/common/hash_calculator.cc b/common/hash_calculator.cc
index 60812d5..ea56bea 100644
--- a/common/hash_calculator.cc
+++ b/common/hash_calculator.cc
@@ -125,4 +125,18 @@
return true;
}
+std::string HashCalculator::SHA256Digest(std::string_view blob) {
+ std::vector<unsigned char> hash;
+ HashCalculator::RawHashOfBytes(blob.data(), blob.size(), &hash);
+ return HexEncode(hash);
+}
+
+std::string HashCalculator::SHA256Digest(std::vector<unsigned char> blob) {
+ return SHA256Digest(ToStringView(blob));
+}
+
+std::string HashCalculator::SHA256Digest(std::vector<char> blob) {
+ return SHA256Digest(ToStringView(blob));
+}
+
} // namespace chromeos_update_engine