rvargas@google.com | f5661ca | 2011-03-24 19:00:20 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
jhawkins@chromium.org | c2ad1e3 | 2009-11-04 19:29:58 | [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 | c2ad1e3 | 2009-11-04 19:29:58 | [diff] [blame] | 7 | |
avi | 9b6f4293 | 2015-12-26 22:15:14 | [diff] [blame] | 8 | #include <stddef.h> |
| 9 | |
Henrik Grunell | fc4ffc7 | 2017-11-30 11:56:44 | [diff] [blame] | 10 | #include <string> |
| 11 | |
darin@chromium.org | 0bea725 | 2011-08-05 15:34:00 | [diff] [blame] | 12 | #include "base/base_export.h" |
rvargas@google.com | f5661ca | 2011-03-24 19:00:20 | [diff] [blame] | 13 | |
jhawkins@chromium.org | c2ad1e3 | 2009-11-04 19:29:58 | [diff] [blame] | 14 | namespace base { |
| 15 | |
pkasting@chromium.org | b13b9bd | 2011-09-28 21:15:27 | [diff] [blame] | 16 | // These functions perform SHA-1 operations. |
jhawkins@chromium.org | c2ad1e3 | 2009-11-04 19:29:58 | [diff] [blame] | 17 | |
pkasting@chromium.org | b13b9bd | 2011-09-28 21:15:27 | [diff] [blame] | 18 | static const size_t kSHA1Length = 20; // Length in bytes of a SHA-1 hash. |
jhawkins@chromium.org | c2ad1e3 | 2009-11-04 19:29:58 | [diff] [blame] | 19 | |
| 20 | // Computes the SHA-1 hash of the input string |str| and returns the full |
| 21 | // hash. |
Henrik Grunell | fc4ffc7 | 2017-11-30 11:56:44 | [diff] [blame] | 22 | BASE_EXPORT std::string SHA1HashString(const std::string& str); |
jhawkins@chromium.org | c2ad1e3 | 2009-11-04 19:29:58 | [diff] [blame] | 23 | |
hans@chromium.org | 5035f68 | 2011-03-13 21:17:20 | [diff] [blame] | 24 | // Computes the SHA-1 hash of the |len| bytes in |data| and puts the hash |
pkasting@chromium.org | b13b9bd | 2011-09-28 21:15:27 | [diff] [blame] | 25 | // in |hash|. |hash| must be kSHA1Length bytes long. |
darin@chromium.org | 0bea725 | 2011-08-05 15:34:00 | [diff] [blame] | 26 | BASE_EXPORT void SHA1HashBytes(const unsigned char* data, size_t len, |
| 27 | unsigned char* hash); |
hans@chromium.org | 5035f68 | 2011-03-13 21:17:20 | [diff] [blame] | 28 | |
jhawkins@chromium.org | c2ad1e3 | 2009-11-04 19:29:58 | [diff] [blame] | 29 | } // namespace base |
| 30 | |
| 31 | #endif // BASE_SHA1_H_ |