| 6 | #define BASE_HASH_SHA1_H_ |
| 7 |
| 8 | #include <stddef.h> |
| 9 |
| 10 | #include <array> |
| 11 | #include <string> |
| 12 |
| 13 | #include "base/base_export.h" |
| 14 | #include "base/containers/span.h" |
| 15 |
| 16 | namespace base { |
| 17 |
| 18 | // These functions perform SHA-1 operations. |
| 19 |
| 20 | enum { kSHA1Length = 20 }; // Length in bytes of a SHA-1 hash. |
| 21 |
| 22 | // The output of a SHA-1 operation. |
| 23 | using SHA1Digest = std::array<uint8_t, kSHA1Length>; |
| 24 |
| 25 | // Computes the SHA-1 hash of the input |data| and returns the full hash. |
| 26 | BASE_EXPORT SHA1Digest SHA1HashSpan(span<const uint8_t> data); |
| 27 |
| 28 | // Computes the SHA-1 hash of the input string |str| and returns the full |
| 29 | // hash. |
| 30 | BASE_EXPORT std::string SHA1HashString(const std::string& str); |
| 31 |
| 32 | // Computes the SHA-1 hash of the |len| bytes in |data| and puts the hash |
| 33 | // in |hash|. |hash| must be kSHA1Length bytes long. |
| 34 | BASE_EXPORT void SHA1HashBytes(const unsigned char* data, |
| 35 | size_t len, |
| 36 | unsigned char* hash); |
| 37 |
| 38 | } // namespace base |
| 39 |
| 40 | #endif // BASE_HASH_SHA1_H_ |
| 41 |