Drop the AGPL license in favor of a source-available license. See the blog post [1] for details. [1] https://www.scylladb.com/2024/12/18/why-were-moving-to-a-source-available-license/
44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
/*
|
|
* Copyright (C) 2019-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
|
|
*/
|
|
|
|
#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> {};
|