blob: 7e279d3e943837dfc72f15ca6bb55c339de529a3 [file] [log] [blame]
[email protected]da7582b72012-01-10 19:10:331// Copyright (c) 2012 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commitd7cae122008-07-26 21:49:384
[email protected]4b559b4d2011-04-14 17:37:145#ifndef CRYPTO_SHA2_H_
6#define CRYPTO_SHA2_H_
initial.commitd7cae122008-07-26 21:49:387
8#include <string>
9
[email protected]daf079a2013-04-17 21:42:4010#include "base/strings/string_piece.h"
[email protected]d613a9902011-08-05 20:59:1111#include "crypto/crypto_export.h"
[email protected]82091cc2011-06-17 21:11:1312
[email protected]4b559b4d2011-04-14 17:37:1413namespace crypto {
initial.commitd7cae122008-07-26 21:49:3814
15// These functions perform SHA-256 operations.
16//
17// Functions for SHA-384 and SHA-512 can be added when the need arises.
18
[email protected]b13b9bd2011-09-28 21:15:2719static const size_t kSHA256Length = 32; // Length in bytes of a SHA-256 hash.
initial.commitd7cae122008-07-26 21:49:3820
21// Computes the SHA-256 hash of the input string 'str' and stores the first
22// 'len' bytes of the hash in the output buffer 'output'. If 'len' > 32,
23// only 32 bytes (the full hash) are stored in the 'output' buffer.
[email protected]da7582b72012-01-10 19:10:3324CRYPTO_EXPORT void SHA256HashString(const base::StringPiece& str,
[email protected]d613a9902011-08-05 20:59:1125 void* output, size_t len);
initial.commitd7cae122008-07-26 21:49:3826
[email protected]e1d6a592010-09-03 21:02:1527// Convenience version of the above that returns the result in a 32-byte
28// string.
[email protected]da7582b72012-01-10 19:10:3329CRYPTO_EXPORT std::string SHA256HashString(const base::StringPiece& str);
[email protected]e1d6a592010-09-03 21:02:1530
[email protected]4b559b4d2011-04-14 17:37:1431} // namespace crypto
initial.commitd7cae122008-07-26 21:49:3832
[email protected]4b559b4d2011-04-14 17:37:1433#endif // CRYPTO_SHA2_H_