rvargas@google.com | 73eb5d0 | 2011-03-25 04:00:20 +0900 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
jhawkins@chromium.org | f64907f | 2009-11-05 04:29:58 +0900 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef BASE_SHA1_H_ |
| 6 | #define BASE_SHA1_H_ |
jhawkins@chromium.org | f64907f | 2009-11-05 04:29:58 +0900 | [diff] [blame] | 7 | |
avi | a6a6a68 | 2015-12-27 07:15:14 +0900 | [diff] [blame] | 8 | #include <stddef.h> |
| 9 | |
jhawkins@chromium.org | f64907f | 2009-11-05 04:29:58 +0900 | [diff] [blame] | 10 | #include <string> |
| 11 | |
darin@chromium.org | e585bed | 2011-08-06 00:34:00 +0900 | [diff] [blame] | 12 | #include "base/base_export.h" |
rvargas@google.com | 73eb5d0 | 2011-03-25 04:00:20 +0900 | [diff] [blame] | 13 | |
jhawkins@chromium.org | f64907f | 2009-11-05 04:29:58 +0900 | [diff] [blame] | 14 | namespace base { |
| 15 | |
pkasting@chromium.org | bd6391d | 2011-09-29 06:15:27 +0900 | [diff] [blame] | 16 | // These functions perform SHA-1 operations. |
jhawkins@chromium.org | f64907f | 2009-11-05 04:29:58 +0900 | [diff] [blame] | 17 | |
pkasting@chromium.org | bd6391d | 2011-09-29 06:15:27 +0900 | [diff] [blame] | 18 | static const size_t kSHA1Length = 20; // Length in bytes of a SHA-1 hash. |
jhawkins@chromium.org | f64907f | 2009-11-05 04:29:58 +0900 | [diff] [blame] | 19 | |
| 20 | // Computes the SHA-1 hash of the input string |str| and returns the full |
| 21 | // hash. |
darin@chromium.org | e585bed | 2011-08-06 00:34:00 +0900 | [diff] [blame] | 22 | BASE_EXPORT std::string SHA1HashString(const std::string& str); |
jhawkins@chromium.org | f64907f | 2009-11-05 04:29:58 +0900 | [diff] [blame] | 23 | |
hans@chromium.org | 273df68 | 2011-03-14 06:17:20 +0900 | [diff] [blame] | 24 | // Computes the SHA-1 hash of the |len| bytes in |data| and puts the hash |
pkasting@chromium.org | bd6391d | 2011-09-29 06:15:27 +0900 | [diff] [blame] | 25 | // in |hash|. |hash| must be kSHA1Length bytes long. |
darin@chromium.org | e585bed | 2011-08-06 00:34:00 +0900 | [diff] [blame] | 26 | BASE_EXPORT void SHA1HashBytes(const unsigned char* data, size_t len, |
| 27 | unsigned char* hash); |
hans@chromium.org | 273df68 | 2011-03-14 06:17:20 +0900 | [diff] [blame] | 28 | |
jhawkins@chromium.org | f64907f | 2009-11-05 04:29:58 +0900 | [diff] [blame] | 29 | } // namespace base |
| 30 | |
| 31 | #endif // BASE_SHA1_H_ |