BTCP-Rebase/src/crypto/sha256.h

36 lines
915 B
C
Raw Normal View History

// Copyright (c) 2014-2017 The Bitcoin Core developers
2014-10-26 01:23:23 -07:00
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
2014-11-19 13:17:58 -08:00
#ifndef BITCOIN_CRYPTO_SHA256_H
#define BITCOIN_CRYPTO_SHA256_H
2014-10-26 01:23:23 -07:00
#include <stdint.h>
#include <stdlib.h>
2017-07-13 23:26:04 -07:00
#include <string>
2014-10-26 01:23:23 -07:00
/** A hasher class for SHA-256. */
class CSHA256
{
private:
uint32_t s[8];
unsigned char buf[64];
uint64_t bytes;
2014-10-26 01:23:23 -07:00
public:
static const size_t OUTPUT_SIZE = 32;
CSHA256();
CSHA256& Write(const unsigned char* data, size_t len);
void Finalize(unsigned char hash[OUTPUT_SIZE]);
2018-03-28 18:34:51 -07:00
void FinalizeNoPadding(unsigned char hash[OUTPUT_SIZE], bool enforce_compression = true);
2014-10-26 01:23:23 -07:00
CSHA256& Reset();
};
2017-07-13 23:26:04 -07:00
/** Autodetect the best available SHA256 implementation.
* Returns the name of the implementation.
*/
std::string SHA256AutoDetect();
2014-11-19 13:17:58 -08:00
#endif // BITCOIN_CRYPTO_SHA256_H