Files
chaos/Chaos/Cipher/Block/Encryptor.hpp
hashlag cdcab2f4f7 Mark all Block::Encryptor<> methods const.
This allows for convenient usage of const Encryptor<Impl> &.
2026-01-31 23:56:25 +03:00

46 lines
843 B
C++

#ifndef CHAOS_CIPHER_BLOCK_ENCRYPTOR_HPP
#define CHAOS_CIPHER_BLOCK_ENCRYPTOR_HPP
namespace Chaos::Cipher::Block
{
template<typename T>
class Encryptor
{
public:
template<typename OutputIt, typename InputIt>
void EncryptBlock(OutputIt out, InputIt inBegin, InputIt inEnd) const
{
Impl().EncryptBlock(out, inBegin, inEnd);
}
template<typename Block>
auto EncryptBlock(Block block) const
{
return Impl().EncryptBlock(block);
}
auto GetBlockSize() const
{
return Impl().GetBlockSize();
}
protected:
Encryptor() = default;
private:
const T & Impl() const
{
return static_cast<const T &>(*this);
}
T & Impl()
{
return static_cast<T &>(*this);
}
};
} // namespace Chaos::Cipher::Block
#endif // CHAOS_CIPHER_BLOCK_ENCRYPTOR_HPP