StormByte C++ Library: Crypto module 1.0.0
StormByte-Crypto is a StormByte library module for handling cryptographic operations
Loading...
Searching...
No Matches
symmetric.hxx
1#pragma once
2
3#include <StormByte/crypto/crypter.hxx>
4
9namespace StormByte::Crypto {
16 class STORMBYTE_CRYPTO_PUBLIC Symmetric final: public Crypter {
17 public:
27 Symmetric(const Algorithm::Symmetric& algorithm, const size_t& password_size = 16) noexcept;
28
38 explicit Symmetric(const Algorithm::Symmetric& algorithm, const std::string& password) noexcept;
39
40 // Default constructors, destructors, and assignment operators
48 Symmetric(const Symmetric& crypter) = default;
49
57 Symmetric(Symmetric&& crypter) noexcept = default;
58
64 ~Symmetric() noexcept override = default;
65
74 Symmetric& operator=(const Symmetric& crypter) = default;
75
84 Symmetric& operator=(Symmetric&& crypter) noexcept = default;
85
94 [[nodiscard]]
95 Expected<std::string, Exception> Encrypt(const std::string& input) const noexcept override;
96
105 [[nodiscard]]
106 Expected<Buffer::Simple, Exception> Encrypt(const Buffer::Simple& buffer) const noexcept override;
107
116 [[nodiscard]]
117 Buffer::Consumer Encrypt(const Buffer::Consumer consumer) const noexcept override;
118
127 [[nodiscard]]
128 Expected<std::string, Exception> Decrypt(const std::string& input) const noexcept override;
129
138 [[nodiscard]]
139 Expected<Buffer::Simple, Exception> Decrypt(const Buffer::Simple& buffer) const noexcept override;
140
149 [[nodiscard]]
150 Buffer::Consumer Decrypt(const Buffer::Consumer consumer) const noexcept override;
151
159 const std::string& Password() const noexcept;
160
168 void Password(const std::string& password) noexcept;
169
178 void Password(std::string&& password) noexcept;
179
180 private:
181 Algorithm::Symmetric m_algorithm;
182 std::string m_password;
183 };
184}
An abstract base class for encryption and decryption operations.
Definition crypter.hxx:21
A class representing an exception in the crypto module.
Definition exception.hxx:15
A class for managing symmetric encryption and decryption.
Definition symmetric.hxx:16
Symmetric(const Algorithm::Symmetric &algorithm, const size_t &password_size=16) noexcept
Constructs a Symmetric instance with a randomly generated password.
The namespace containing cryptographic algorithms.