Files
thehub/libs/crypto/sha512.h

51 lines
1.4 KiB
C++

/*
* This file is part of the Flowee project
* Copyright (C) 2014 The Bitcoin Core developers
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef FLOWEE_CRYPTO_SHA512_H
#define FLOWEE_CRYPTO_SHA512_H
#include <cstdint>
#include <cassert>
#include <string>
/** A hasher class for SHA-512. */
class CSHA512
{
private:
uint64_t s[8];
unsigned char buf[128];
size_t bytes;
public:
static const size_t OUTPUT_SIZE = 64;
CSHA512();
inline CSHA512& write(const char* data, int len) {
assert(len >= 0);
return write(reinterpret_cast<const unsigned char*>(data), size_t(len));
}
CSHA512& write(const unsigned char* data, size_t len);
inline void finalize(char *hash) {
return finalize(reinterpret_cast<unsigned char*>(hash));
}
void finalize(unsigned char hash[OUTPUT_SIZE]);
CSHA512& reset();
};
#endif