#pragma once #include #include "RsaPrivateKey.hpp" namespace drp::util::crypto { /** * Represent an RSA public key. */ class RsaPublicKey { public: RsaPublicKey(); explicit RsaPublicKey(const std::vector& data, int padMode); /** * Encrypt data with the public key. Can only be decrypted with the corresponding private key. * @param plainData the plain data. * @return the encrypted data. */ [[nodiscard]] std::vector encrypt(const std::vector& plainData) const; [[nodiscard]] std::vector serialize() const; static RsaPublicKey deserialize(std::vector& data); private: [[nodiscard]] std::unique_ptr getOpenSslKey() const; int padMode {}; std::vector _data; }; }