Allow aos::Sha256() to take a file path

This enables writing some tests where we want to conveniently compare
that the contents of two files are identical or haven't changed from
some known-good baseline.

Change-Id: I7f62fb1b3fffb7feafd34dd776e8a4981820b7d6
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/sha256.cc b/aos/sha256.cc
index ae83792..cfeccde 100644
--- a/aos/sha256.cc
+++ b/aos/sha256.cc
@@ -7,6 +7,8 @@
 #include "absl/types/span.h"
 #include "openssl/sha.h"
 
+#include "aos/util/file.h"
+
 namespace aos {
 
 std::string Sha256(const absl::Span<const uint8_t> str) {
@@ -23,4 +25,13 @@
   return ss.str();
 }
 
+std::string Sha256(std::string_view str) {
+  return Sha256({reinterpret_cast<const uint8_t *>(str.data()), str.size()});
+}
+
+std::string Sha256OfFile(std::filesystem::path file) {
+  const std::string contents = aos::util::ReadFileToStringOrDie(file.string());
+  return Sha256(contents);
+}
+
 }  // namespace aos