2022-05-26 22:30:59 +02:00
|
|
|
#ifndef GCRYPTCLI_MODULE_DATAFORMATTER_H
|
|
|
|
#define GCRYPTCLI_MODULE_DATAFORMATTER_H
|
|
|
|
|
|
|
|
#include <GCrypt/Block.h>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include "Configuration.h"
|
|
|
|
|
|
|
|
using namespace Leonetienne::GCrypt;
|
|
|
|
|
|
|
|
// This class has the task to format Blocks to various formats.
|
|
|
|
class ModuleDataFormatter {
|
|
|
|
public:
|
2022-05-27 02:13:05 +02:00
|
|
|
//! Will format a single block to a given iobase
|
2022-05-26 22:30:59 +02:00
|
|
|
static std::string FormatBlock(const Block& block, const Configuration::IOBASE_FORMAT base);
|
2022-05-27 02:13:05 +02:00
|
|
|
|
|
|
|
//! Will parse a string of a given iobase to a block
|
2022-05-26 23:22:04 +02:00
|
|
|
static Block StringToBlock(const std::string& str, const Configuration::IOBASE_FORMAT base);
|
2022-05-26 22:30:59 +02:00
|
|
|
|
2022-05-27 02:13:05 +02:00
|
|
|
//! Will format a vector of blocks to a given iobase
|
|
|
|
static std::string FormatBlocks(const std::vector<Block>& blocks, const Configuration::IOBASE_FORMAT base);
|
|
|
|
|
2022-05-26 22:30:59 +02:00
|
|
|
|
|
|
|
private:
|
2022-05-27 02:13:05 +02:00
|
|
|
static std::string Bin2CustomBase(const std::string& bin, const std::vector<std::string>& customSet, std::size_t minLen, const std::string& seperator = "");
|
2022-05-26 22:30:59 +02:00
|
|
|
static std::string CustomBase2Bin(const std::string& in, const std::vector<std::string>& customSet, const std::string& seperator = "");
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|