Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "blimp/common/blob_cache/id_util.h" | |
| 6 | |
| 7 #include "base/sha1.h" | |
| 8 #include "base/strings/string_number_conversions.h" | |
| 9 #include "base/strings/string_util.h" | |
| 10 #include "blimp/common/blob_cache/blob_cache.h" | |
| 11 | |
| 12 namespace blimp { | |
| 13 | |
| 14 const BlobId CalculateBlobId(const void* data, size_t data_size) { | |
| 15 std::vector<unsigned char> sha1_hash(base::kSHA1Length); | |
| 16 base::SHA1HashBytes(static_cast<const unsigned char*>(data), data_size, | |
|
davidben
2016/04/22 16:39:49
Drive-by comment: why is this using SHA-1 and not
| |
| 17 sha1_hash.data()); | |
| 18 return std::string(reinterpret_cast<char*>(sha1_hash.data()), | |
| 19 sha1_hash.size()); | |
| 20 } | |
| 21 | |
| 22 const std::string FormatBlobId(const BlobId& data) { | |
| 23 DCHECK_EQ(base::kSHA1Length, data.length()); | |
| 24 return base::ToLowerASCII(base::HexEncode(data.data(), data.length())); | |
| 25 } | |
| 26 | |
| 27 } // namespace blimp | |
| OLD | NEW |