Files
scylladb/utils/hashers.hh
Pavel Emelyanov 8ccb4a1045 Merge 'db: remove unused includes ' from Kefu Chai
these unused includes are identified by clang-include-cleaner.
after auditing the source files, all of the reports have been
confirmed.

please note, since we have `using seastar::shared_ptr` in
`seastarx.h`, this renders `#include <seastar/core/shared_ptr.hh>`
unnecessary if we don't need the full definition of `seastar::shared_ptr`.

so, in this change, all the unused includes are removed.

---

it's a cleanup, hence no need to backport.

Closes scylladb/scylladb#20963

* github.com:scylladb/scylladb:
  .github: add db to iwyu's CLEANER_DIR
  db: remove unused includes
2024-10-07 10:55:48 +03:00

44 lines
1.1 KiB
C++

/*
* Copyright (C) 2019-present ScyllaDB
*/
/*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#pragma once
#include <memory>
#include "bytes.hh"
#include "utils/hashing.hh"
#include <memory>
template<typename H>
concept HasherReturningBytes = HasherReturning<H, bytes>;
class md5_hasher;
template <typename T, size_t size> class cryptopp_hasher : public hasher {
struct impl;
std::unique_ptr<impl> _impl;
public:
cryptopp_hasher();
~cryptopp_hasher();
cryptopp_hasher(cryptopp_hasher&&) noexcept;
cryptopp_hasher(const cryptopp_hasher&);
cryptopp_hasher& operator=(cryptopp_hasher&&) noexcept;
cryptopp_hasher& operator=(const cryptopp_hasher&);
bytes finalize();
std::array<uint8_t, size> finalize_array();
void update(const char* ptr, size_t length) noexcept override;
// Use update and finalize to compute the hash over the full view.
static bytes calculate(const std::string_view& s);
};
class md5_hasher final : public cryptopp_hasher<md5_hasher, 16> {};
class sha256_hasher final : public cryptopp_hasher<sha256_hasher, 32> {};