blob: d575815f886796866abe08cfe55c5132b377a561 [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
avidd373b8b2015-12-21 21:34:438#include <stddef.h>
9
initial.commitd7cae122008-07-26 21:49:3810#include <string>
11
[email protected]daf079a2013-04-17 21:42:4012#include "base/strings/string_piece.h"
[email protected]d613a9902011-08-05 20:59:1113#include "crypto/crypto_export.h"
[email protected]82091cc2011-06-17 21:11:1314
[email protected]4b559b4d2011-04-14 17:37:1415namespace crypto {
initial.commitd7cae122008-07-26 21:49:3816
17// These functions perform SHA-256 operations.
18//
19// Functions for SHA-384 and SHA-512 can be added when the need arises.
20
[email protected]b13b9bd2011-09-28 21:15:2721static const size_t kSHA256Length = 32; // Length in bytes of a SHA-256 hash.
initial.commitd7cae122008-07-26 21:49:3822
23// Computes the SHA-256 hash of the input string 'str' and stores the first
24// 'len' bytes of the hash in the output buffer 'output'. If 'len' > 32,
25// only 32 bytes (the full hash) are stored in the 'output' buffer.
[email protected]da7582b72012-01-10 19:10:3326CRYPTO_EXPORT void SHA256HashString(const base::StringPiece& str,
[email protected]d613a9902011-08-05 20:59:1127 void* output, size_t len);
initial.commitd7cae122008-07-26 21:49:3828
[email protected]e1d6a592010-09-03 21:02:1529// Convenience version of the above that returns the result in a 32-byte
30// string.
[email protected]da7582b72012-01-10 19:10:3331CRYPTO_EXPORT std::string SHA256HashString(const base::StringPiece& str);
[email protected]e1d6a592010-09-03 21:02:1532
[email protected]4b559b4d2011-04-14 17:37:1433} // namespace crypto
initial.commitd7cae122008-07-26 21:49:3834
[email protected]4b559b4d2011-04-14 17:37:1435#endif // CRYPTO_SHA2_H_