sha1.h 856 Bytes
Newer Older
gejun's avatar
gejun committed
1 2 3 4
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6
#ifndef BUTIL_SHA1_H_
#define BUTIL_SHA1_H_
gejun's avatar
gejun committed
7 8 9

#include <string>

10
#include "butil/base_export.h"
gejun's avatar
gejun committed
11

12
namespace butil {
gejun's avatar
gejun committed
13 14 15 16 17 18 19

// These functions perform SHA-1 operations.

static const size_t kSHA1Length = 20;  // Length in bytes of a SHA-1 hash.

// Computes the SHA-1 hash of the input string |str| and returns the full
// hash.
20
BUTIL_EXPORT std::string SHA1HashString(const std::string& str);
gejun's avatar
gejun committed
21 22 23

// Computes the SHA-1 hash of the |len| bytes in |data| and puts the hash
// in |hash|. |hash| must be kSHA1Length bytes long.
24
BUTIL_EXPORT void SHA1HashBytes(const unsigned char* data, size_t len,
gejun's avatar
gejun committed
25 26
                               unsigned char* hash);

27
}  // namespace butil
gejun's avatar
gejun committed
28

29
#endif  // BUTIL_SHA1_H_