blob: 349a606a3d7d51ac27480b54b470f38194d9d7b3 [file] [log] [blame]
[email protected]f5661ca2011-03-24 19:00:201// Copyright (c) 2011 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_
[email protected]32b76ef2010-07-26 23:08:247#pragma once
initial.commitd7cae122008-07-26 21:49:388
9#include <string>
10
[email protected]4b559b4d2011-04-14 17:37:1411namespace crypto {
initial.commitd7cae122008-07-26 21:49:3812
13// These functions perform SHA-256 operations.
14//
15// Functions for SHA-384 and SHA-512 can be added when the need arises.
16
17enum {
18 SHA256_LENGTH = 32 // length in bytes of a SHA-256 hash
19};
20
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]4b559b4d2011-04-14 17:37:1424void SHA256HashString(const std::string& str,
25 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]4b559b4d2011-04-14 17:37:1429std::string SHA256HashString(const std::string& 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_