OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
util/common/hash.hpp
Go to the documentation of this file.
1// Copyright (c) 2021 MIT Digital Currency Initiative,
2// Federal Reserve Bank of Boston
3// Distributed under the MIT software license, see the accompanying
4// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6#ifndef OPENCBDC_TX_SRC_COMMON_HASH_H_
7#define OPENCBDC_TX_SRC_COMMON_HASH_H_
8
9#include "crypto/siphash.h"
10
11#include <array>
12#include <sstream>
13
14namespace cbdc {
16 static constexpr const int hash_size = 32;
17
19 using hash_t = std::array<unsigned char, cbdc::hash_size>;
20
24 auto to_string(const hash_t& val) -> std::string;
25
29 auto hash_from_hex(const std::string& val) -> hash_t;
30
35 auto hash_data(const std::byte* data, size_t len) -> hash_t;
36}
37
38#endif // OPENCBDC_TX_SRC_COMMON_HASH_H_
std::array< unsigned char, cbdc::hash_size > hash_t
SHA256 hash container.
auto hash_data(const std::byte *data, size_t len) -> hash_t
Calculates the SHA256 hash of the specified data.
auto hash_from_hex(const std::string &val) -> hash_t
Parses a hexadecimal representation of a hash.
auto to_string(const hash_t &val) -> std::string
Converts a hash to a hexadecimal string.