Index: blimp/common/blob_cache/sha1_util.cc |
diff --git a/blimp/common/blob_cache/sha1_util.cc b/blimp/common/blob_cache/sha1_util.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..14b7009829bbe10cbd9aabb4df7813de21c84944 |
--- /dev/null |
+++ b/blimp/common/blob_cache/sha1_util.cc |
@@ -0,0 +1,25 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "blimp/common/blob_cache/sha1_util.h" |
+ |
+#include "base/sha1.h" |
+#include "base/strings/string_number_conversions.h" |
+#include "base/strings/string_util.h" |
+ |
+namespace blimp { |
+ |
+std::vector<unsigned char> ToSHA1HashBytes(const void* data, size_t data_size) { |
+ std::vector<unsigned char> sha1_hash(base::kSHA1Length); |
+ base::SHA1HashBytes(static_cast<const unsigned char*>(data), data_size, |
+ sha1_hash.data()); |
+ |
+ return sha1_hash; |
+} |
+ |
+const std::string FormatSHA1Hash(const void* data) { |
Kevin M
2016/04/15 17:28:51
When data becomes a string, DCHECK it for a correc
nyquist
2016/04/16 00:25:30
Done.
|
+ return base::ToLowerASCII(base::HexEncode(data, base::kSHA1Length)); |
+} |
+ |
+} // namespace blimp |