3#include <StormByte/buffer/consumer.hxx>
4#include <StormByte/clonable.hxx>
5#include <StormByte/crypto/typedefs.hxx>
6#include <StormByte/crypto/visibility.h>
12namespace StormByte::Crypto::Hasher {
30 class STORMBYTE_CRYPTO_PUBLIC
Generic:
public StormByte::Clonable<Generic> {
69 inline
bool Hash(std::span<const std::
byte> input, Buffer::WriteOnly& output) const noexcept {
70 return DoHash(input, output);
79 inline bool Hash(
const Buffer::ReadOnly& input, Buffer::WriteOnly& output)
const noexcept {
80 return DoHash(
const_cast<Buffer::ReadOnly&
>(input), output, ReadMode::Copy);
89 inline bool Hash(Buffer::ReadOnly& input, Buffer::WriteOnly& output)
const noexcept {
90 return DoHash(input, output, ReadMode::Move);
99 inline Buffer::Consumer
Hash(Buffer::Consumer consumer, ReadMode mode = ReadMode::Move)
const noexcept {
100 return DoHash(consumer, mode);
107 inline enum Type
Type() const noexcept {
129 bool DoHash(Buffer::ReadOnly& input, Buffer::WriteOnly& output, ReadMode mode)
const noexcept;
138 virtual bool DoHash(std::span<const std::byte> input, Buffer::WriteOnly& output)
const noexcept = 0;
146 virtual Buffer::Consumer DoHash(Buffer::Consumer consumer, ReadMode mode)
const noexcept = 0;
154 STORMBYTE_CRYPTO_PUBLIC Generic::PointerType Create(Type type)
noexcept;
A generic hasher class.
Definition generic.hxx:30
bool Hash(const Buffer::ReadOnly &input, Buffer::WriteOnly &output) const noexcept
Hash data from input buffer to output buffer.
Definition generic.hxx:79
Generic(Generic &&other) noexcept=default
Move constructor.
enum Type m_type
The type of hasher.
Definition generic.hxx:112
enum Type Type() const noexcept
Gets the type of hasher.
Definition generic.hxx:107
Buffer::Consumer Hash(Buffer::Consumer consumer, ReadMode mode=ReadMode::Move) const noexcept
Hash data from a Consumer buffer.
Definition generic.hxx:99
bool Hash(Buffer::ReadOnly &input, Buffer::WriteOnly &output) const noexcept
Hash data from input buffer to output buffer, moving the input data.
Definition generic.hxx:89
Generic(enum Type type)
Constructor.
Definition generic.hxx:118
virtual ~Generic() noexcept=default
Virtual destructor.
Generic(const Generic &other)=default
Copy constructor.