| Kristian Monsen | ddb351d | 2011-06-28 21:49:31 +0100 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| Patrick Scott | c7f5f85 | 2010-02-04 10:37:17 -0500 | [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_ |
| Iain Merrick | 3345a68 | 2010-10-19 14:37:37 +0100 | [diff] [blame] | 7 | #pragma once |
| Patrick Scott | c7f5f85 | 2010-02-04 10:37:17 -0500 | [diff] [blame] | 8 | |
| 9 | #include <string> |
| 10 | |
| Kristian Monsen | ddb351d | 2011-06-28 21:49:31 +0100 | [diff] [blame] | 11 | #include "base/base_api.h" |
| 12 | |
| Patrick Scott | c7f5f85 | 2010-02-04 10:37:17 -0500 | [diff] [blame] | 13 | namespace base { |
| 14 | |
| 15 | // This function performs SHA-1 operations. |
| 16 | |
| 17 | enum { |
| 18 | SHA1_LENGTH = 20 // Length in bytes of a SHA-1 hash. |
| 19 | }; |
| 20 | |
| 21 | // Computes the SHA-1 hash of the input string |str| and returns the full |
| 22 | // hash. |
| Kristian Monsen | ddb351d | 2011-06-28 21:49:31 +0100 | [diff] [blame] | 23 | BASE_API std::string SHA1HashString(const std::string& str); |
| 24 | |
| 25 | // Computes the SHA-1 hash of the |len| bytes in |data| and puts the hash |
| 26 | // in |hash|. |hash| must be SHA1_LENGTH bytes long. |
| 27 | BASE_API void SHA1HashBytes(const unsigned char* data, size_t len, |
| 28 | unsigned char* hash); |
| Patrick Scott | c7f5f85 | 2010-02-04 10:37:17 -0500 | [diff] [blame] | 29 | |
| 30 | } // namespace base |
| 31 | |
| 32 | #endif // BASE_SHA1_H_ |