1ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen// Copyright (c) 2011 The Chromium Authors. All rights reserved.
2c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// Use of this source code is governed by a BSD-style license that can be
3c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// found in the LICENSE file.
4c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
5c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#ifndef BASE_SHA1_H_
6c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define BASE_SHA1_H_
73345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick#pragma once
8c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
9c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#include <string>
10c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
11ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "base/base_api.h"
12ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
13c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scottnamespace base {
14c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
15c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// This function performs SHA-1 operations.
16c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
17c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scottenum {
18c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  SHA1_LENGTH = 20  // Length in bytes of a SHA-1 hash.
19c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott};
20c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
21c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// Computes the SHA-1 hash of the input string |str| and returns the full
22c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// hash.
23ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian MonsenBASE_API std::string SHA1HashString(const std::string& str);
24ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
25ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen// Computes the SHA-1 hash of the |len| bytes in |data| and puts the hash
26ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen// in |hash|. |hash| must be SHA1_LENGTH bytes long.
27ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian MonsenBASE_API void SHA1HashBytes(const unsigned char* data, size_t len,
28ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen                            unsigned char* hash);
29c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
30c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott}  // namespace base
31c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
32c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#endif  // BASE_SHA1_H_
33