OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BASE_SHA1_H_ | 5 #ifndef BASE_SHA1_H_ |
6 #define BASE_SHA1_H_ | 6 #define BASE_SHA1_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/base_export.h" | 10 #include "base/base_export.h" |
11 | 11 |
12 namespace base { | 12 namespace base { |
13 | 13 |
14 // These functions perform SHA-1 operations. | 14 // These functions perform SHA-1 operations. |
15 | 15 |
16 static const size_t kSHA1Length = 20; // Length in bytes of a SHA-1 hash. | 16 static const size_t kSHA1Length = 20; // Length in bytes of a SHA-1 hash. |
17 | 17 |
18 // Computes the SHA-1 hash of the input string |str| and returns the full | 18 // Computes the SHA-1 hash of the input string |str| and returns the full |
19 // hash. | 19 // hash. |
20 BASE_EXPORT std::string SHA1HashString(const std::string& str); | 20 BASE_EXPORT std::string SHA1HashString(const std::string& str); |
21 | 21 |
22 // Computes the SHA-1 hash of the |len| bytes in |data| and puts the hash | 22 // Computes the SHA-1 hash of the |len| bytes in |data| and puts the hash |
23 // in |hash|. |hash| must be kSHA1Length bytes long. | 23 // in |hash|. |hash| must be kSHA1Length bytes long. |
24 BASE_EXPORT void SHA1HashBytes(const unsigned char* data, size_t len, | 24 BASE_EXPORT void SHA1HashBytes(const unsigned char* data, size_t len, |
25 unsigned char* hash); | 25 unsigned char* hash); |
26 | 26 |
| 27 // Computes the SHA-1 hash of |file_path| and puts the hash in |hash|. |
| 28 // |hash| must be kSha1Length bytes long. Returns false on error. |
| 29 BASE_EXPORT bool SHA1HashFile(const std::string& file_path, |
| 30 unsigned char* hash); |
| 31 |
27 } // namespace base | 32 } // namespace base |
28 | 33 |
29 #endif // BASE_SHA1_H_ | 34 #endif // BASE_SHA1_H_ |
OLD | NEW |