32 explicit Sha1Sum(std::string_view hex);
38 void parse40(std::span<const char, 40> str);
39 [[nodiscard]] std::string
toString()
const;
42 [[nodiscard]]
bool empty()
const;
50 if (a[i] != other.a[i])
return false;
55 for (
int i :
xrange(5 - 1)) {
56 if (
auto cmp = a[i] <=> other.a[i]; cmp != 0)
return cmp;
58 return a[5 - 1] <=> other.a[5 - 1];
67 std::array<uint32_t, 5> a;
86 void update(std::span<const uint8_t> data);
93 [[nodiscard]]
static Sha1Sum calc(std::span<const uint8_t> data);
96 void transform(std::span<const uint8_t, 64> buffer);
100 uint64_t m_count = 0;
102 std::array<uint8_t, 64> m_buffer;
103 bool m_finalized =
false;
Helper class to perform a sha1 calculation.
Sha1Sum digest()
Get the final hash.
void update(std::span< const uint8_t > data)
Incrementally calculate the hash value.
static Sha1Sum calc(std::span< const uint8_t > data)
Easier to use interface, if you can pass all data in one go.
This class represents the result of a sha1 calculation (a 160-bit value).
bool operator==(const Sha1Sum &other) const
Sha1Sum(UninitializedTag)
void parse40(std::span< const char, 40 > str)
Parse from a 40-character long buffer.
constexpr auto operator<=>(const Sha1Sum &other) const
friend std::ostream & operator<<(std::ostream &os, const Sha1Sum &sum)
std::string toString() const
This file implemented 3 utility functions:
auto sum(InputRange &&range, Proj proj={})
constexpr auto xrange(T e)