Bertini 2 d882924 (2026-10-06 19:56 UTC)
Numerical algebraic geometry library (C++ core)
Loading...
Searching...
No Matches
sha256.hpp
Go to the documentation of this file.
1//This file is part of Bertini 2.
2//
3//sha256.hpp is free software: you can redistribute it and/or modify
4//it under the terms of the GNU General Public License as published by
5//the Free Software Foundation, either version 3 of the License, or
6//(at your option) any later version.
7//
8//sha256.hpp is distributed in the hope that it will be useful,
9//but WITHOUT ANY WARRANTY; without even the implied warranty of
10//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11//GNU General Public License for more details.
12//
13//You should have received a copy of the GNU General Public License
14//along with sha256.hpp. If not, see <http://www.gnu.org/licenses/>.
15//
16// Copyright(C) Bertini2 Development Team
17//
18// See <http://www.gnu.org/licenses/> for a copy of the license,
19// as well as COPYING. Bertini2 is provided with permitted
20// additional terms in the b2/licenses/ directory.
21
35
36#pragma once
37
38#include <array>
39#include <cstdint>
40#include <string>
41#include <string_view>
42
43namespace bertini {
44namespace detail {
45
53{
55 std::array<std::uint8_t, 32> bytes{};
56
58 std::string Hex() const;
59
61 bool operator==(Digest256 const& other) const { return bytes == other.bytes; }
63 bool operator!=(Digest256 const& other) const { return bytes != other.bytes; }
65 bool operator<(Digest256 const& other) const { return bytes < other.bytes; }
66};
67
74Digest256 Sha256(std::string_view data);
75
76} // namespace detail
77} // namespace bertini
Definition configured.hpp:34
Digest256 Sha256(std::string_view data)
SHA-256 (FIPS 180-4) of a byte string.
Definition algorithm_builder.hpp:36
A 256-bit content digest – the output of Sha256, used as a persistent identity key.
Definition sha256.hpp:53
bool operator==(Digest256 const &other) const
Bytewise equality.
Definition sha256.hpp:61
std::string Hex() const
The digest as 64 lowercase hex characters (the cross-session interchange form).
bool operator<(Digest256 const &other) const
Lexicographic byte order, so Digest256 can key ordered containers.
Definition sha256.hpp:65
bool operator!=(Digest256 const &other) const
Bytewise inequality.
Definition sha256.hpp:63
std::array< std::uint8_t, 32 > bytes
The raw 32 digest bytes, big-endian word order per FIPS 180-4.
Definition sha256.hpp:55