diff --git a/GCryptCLI/include/Bases.h b/GCryptCLI/include/Bases.h index d457bd2..a2678a6 100644 --- a/GCryptCLI/include/Bases.h +++ b/GCryptCLI/include/Bases.h @@ -1,6 +1,26 @@ #pragma once #include #include +#include + +// This lookup table holds how many digits a block is long +// in any iobase. +// This cannot be calculated on the fly, as it involves +// arithmetic with involving REALLY big numbers (like, 2^512). +// Here's how to calculate these numbers: +// Print an all 1's block in this format, and check the string size. +// That's it. +auto blockLengthByBase = + std::map({ + std::make_pair(Configuration::IOBASE_FORMAT::BASE_BYTES, 64), + std::make_pair(Configuration::IOBASE_FORMAT::BASE_2, 512), + std::make_pair(Configuration::IOBASE_FORMAT::BASE_8, 171), + std::make_pair(Configuration::IOBASE_FORMAT::BASE_10, 155), + std::make_pair(Configuration::IOBASE_FORMAT::BASE_16, 128), + std::make_pair(Configuration::IOBASE_FORMAT::BASE_64, 86), + std::make_pair(Configuration::IOBASE_FORMAT::BASE_UWU, 125), + std::make_pair(Configuration::IOBASE_FORMAT::BASE_UGH, 125) + }); // Actually useful bases static const std::vector BASE_2 = { "0","1" }; diff --git a/GCryptCLI/src/ModuleDataFormatter.cpp b/GCryptCLI/src/ModuleDataFormatter.cpp index 77f234c..35814b2 100644 --- a/GCryptCLI/src/ModuleDataFormatter.cpp +++ b/GCryptCLI/src/ModuleDataFormatter.cpp @@ -3,34 +3,11 @@ #include #include #include -#include -#include using namespace Leonetienne::GCrypt; using namespace Leonetienne::StringTools; using namespace Leonetienne::GeneralUtility; -namespace { - // This lookup table holds how many digits a block is long - // in any iobase. - // This cannot be calculated on the fly, as it involves - // arithmetic with involving REALLY big numbers (like, 2^512). - // Here's how to calculate these numbers: - // Print an all 1's block in this format, and check the string size. - // That's it. - auto blockLengthByBase = - std::map({ - std::make_pair(Configuration::IOBASE_FORMAT::BASE_BYTES, 64), - std::make_pair(Configuration::IOBASE_FORMAT::BASE_2, 512), - std::make_pair(Configuration::IOBASE_FORMAT::BASE_8, 171), - std::make_pair(Configuration::IOBASE_FORMAT::BASE_10, 155), - std::make_pair(Configuration::IOBASE_FORMAT::BASE_16, 128), - std::make_pair(Configuration::IOBASE_FORMAT::BASE_64, 86), - std::make_pair(Configuration::IOBASE_FORMAT::BASE_UWU, 125), - std::make_pair(Configuration::IOBASE_FORMAT::BASE_UGH, 125) - }); -} - std::string ModuleDataFormatter::FormatBlock( const Block& block, const Configuration::IOBASE_FORMAT base