diff --git a/others/C++/text converter/Makefile b/others/C++/text converter/Makefile new file mode 100644 index 0000000..693e1e3 --- /dev/null +++ b/others/C++/text converter/Makefile @@ -0,0 +1,37 @@ +# 编译器设置 +CXX = g++ +FLTK_CONFIG = fltk-config + +# 编译选项 +CXXFLAGS = -std=c++11 -Wall -Iinclude +LDFLAGS = -static -mwindows `$(FLTK_CONFIG) --use-images --ldstaticflags` -lcrypto -lws2_32 -lcrypt32 + +# 源文件和目标文件 +SRC_DIR = src +OBJ_DIR = obj +SRCS = $(wildcard $(SRC_DIR)/*.cpp) +OBJS = $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(SRCS)) + +# 可执行文件 +TARGET = text_converter.exe + +# 默认目标 +all: $(OBJ_DIR) $(TARGET) + +# 创建obj目录 +$(OBJ_DIR): + mkdir -p $(OBJ_DIR) + +# 生成目标文件 +$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp + $(CXX) $(CXXFLAGS) -c $< -o $@ + +# 链接生成可执行文件 +$(TARGET): $(OBJS) + $(CXX) $^ -o $@ $(LDFLAGS) + +# 清理 +clean: + rm -rf $(OBJ_DIR) $(TARGET) + +.PHONY: all clean diff --git a/others/C++/text converter/include/About.hpp b/others/C++/text converter/include/About.hpp new file mode 100644 index 0000000..a7770ba --- /dev/null +++ b/others/C++/text converter/include/About.hpp @@ -0,0 +1,16 @@ +#ifndef ABOUT_HPP +#define ABOUT_HPP + +#include + +class About { +public: + static std::string getName() { return "文本转换器"; } + static std::string getVersion() { return "1.0.0"; } + static std::string getAuthor() { return "zsyg"; } + static std::string getDescription() { + return "一个简单的文本转换工具,支持文本转换"; + } +}; + +#endif // ABOUT_HPP diff --git a/others/C++/text converter/include/Ascii85Converter.hpp b/others/C++/text converter/include/Ascii85Converter.hpp new file mode 100644 index 0000000..adcebe7 --- /dev/null +++ b/others/C++/text converter/include/Ascii85Converter.hpp @@ -0,0 +1,13 @@ +#ifndef ASCII85CONVERTER_HPP +#define ASCII85CONVERTER_HPP + +#include "Converter.hpp" +#include + +class Ascii85Converter : public Converter { +public: + std::string convert(const std::string& input) override; + std::string getName() const override { return "Ascii85"; } +}; + +#endif // ASCII85CONVERTER_HPP diff --git a/others/C++/text converter/include/Base32Converter.hpp b/others/C++/text converter/include/Base32Converter.hpp new file mode 100644 index 0000000..a518361 --- /dev/null +++ b/others/C++/text converter/include/Base32Converter.hpp @@ -0,0 +1,13 @@ +#ifndef BASE32CONVERTER_HPP +#define BASE32CONVERTER_HPP + +#include "Converter.hpp" +#include + +class Base32Converter : public Converter { +public: + std::string convert(const std::string& input) override; + std::string getName() const override { return "Base32"; } +}; + +#endif // BASE32CONVERTER_HPP diff --git a/others/C++/text converter/include/Base64Converter.hpp b/others/C++/text converter/include/Base64Converter.hpp new file mode 100644 index 0000000..c5a1ab6 --- /dev/null +++ b/others/C++/text converter/include/Base64Converter.hpp @@ -0,0 +1,13 @@ +#ifndef BASE64CONVERTER_HPP +#define BASE64CONVERTER_HPP + +#include "Converter.hpp" +#include + +class Base64Converter : public Converter { +public: + std::string convert(const std::string& input) override; + std::string getName() const override { return "Base64"; } +}; + +#endif // BASE64CONVERTER_HPP diff --git a/others/C++/text converter/include/BinaryConverter.hpp b/others/C++/text converter/include/BinaryConverter.hpp new file mode 100644 index 0000000..540631a --- /dev/null +++ b/others/C++/text converter/include/BinaryConverter.hpp @@ -0,0 +1,14 @@ +#ifndef BINARYCONVERTER_HPP +#define BINARYCONVERTER_HPP + +#include "Converter.hpp" +#include +#include + +class BinaryConverter : public Converter { +public: + std::string convert(const std::string& input) override; + std::string getName() const override { return "二进制"; } +}; + +#endif // BINARYCONVERTER_HPP diff --git a/others/C++/text converter/include/CRC32Converter.hpp b/others/C++/text converter/include/CRC32Converter.hpp new file mode 100644 index 0000000..9b468c5 --- /dev/null +++ b/others/C++/text converter/include/CRC32Converter.hpp @@ -0,0 +1,13 @@ +#ifndef CRC32CONVERTER_HPP +#define CRC32CONVERTER_HPP + +#include "Converter.hpp" +#include + +class CRC32Converter : public Converter { +public: + std::string convert(const std::string& input) override; + std::string getName() const override { return "CRC32"; } +}; + +#endif // CRC32CONVERTER_HPP diff --git a/others/C++/text converter/include/Config.hpp b/others/C++/text converter/include/Config.hpp new file mode 100644 index 0000000..d46f718 --- /dev/null +++ b/others/C++/text converter/include/Config.hpp @@ -0,0 +1,30 @@ +#ifndef CONFIG_HPP +#define CONFIG_HPP + +namespace Config { + constexpr int WINDOW_WIDTH = 450; + constexpr int WINDOW_HEIGHT = 250; + constexpr const char* WINDOW_TITLE = "文本转换器"; + + constexpr int INPUT_X = 70; + constexpr int INPUT_Y = 40; + constexpr int INPUT_WIDTH = 360; + constexpr int INPUT_HEIGHT = 30; + + constexpr int OUTPUT_X = 70; + constexpr int OUTPUT_Y = 100; + constexpr int OUTPUT_WIDTH = 360; + constexpr int OUTPUT_HEIGHT = 30; + + constexpr int CHOICE_X = 70; + constexpr int CHOICE_Y = 160; + constexpr int CHOICE_WIDTH = 120; + constexpr int CHOICE_HEIGHT = 30; + + constexpr int BUTTON_X = 210; + constexpr int BUTTON_Y = 160; + constexpr int BUTTON_WIDTH = 100; + constexpr int BUTTON_HEIGHT = 30; +}; + +#endif // CONFIG_HPP diff --git a/others/C++/text converter/include/Converter.hpp b/others/C++/text converter/include/Converter.hpp new file mode 100644 index 0000000..04c8b95 --- /dev/null +++ b/others/C++/text converter/include/Converter.hpp @@ -0,0 +1,13 @@ +#ifndef CONVERTER_HPP +#define CONVERTER_HPP + +#include + +class Converter { +public: + virtual ~Converter() = default; + virtual std::string convert(const std::string& input) = 0; + virtual std::string getName() const = 0; +}; + +#endif // CONVERTER_HPP diff --git a/others/C++/text converter/include/HexConverter.hpp b/others/C++/text converter/include/HexConverter.hpp new file mode 100644 index 0000000..59874e9 --- /dev/null +++ b/others/C++/text converter/include/HexConverter.hpp @@ -0,0 +1,15 @@ +#ifndef HEXCONVERTER_HPP +#define HEXCONVERTER_HPP + +#include "Converter.hpp" +#include +#include +#include + +class HexConverter : public Converter { +public: + std::string convert(const std::string& input) override; + std::string getName() const override { return "十六进制"; } +}; + +#endif // HEXCONVERTER_HPP diff --git a/others/C++/text converter/include/MD5Converter.hpp b/others/C++/text converter/include/MD5Converter.hpp new file mode 100644 index 0000000..26a2f60 --- /dev/null +++ b/others/C++/text converter/include/MD5Converter.hpp @@ -0,0 +1,13 @@ +#ifndef MD5CONVERTER_HPP +#define MD5CONVERTER_HPP + +#include "Converter.hpp" +#include + +class MD5Converter : public Converter { +public: + std::string convert(const std::string& input) override; + std::string getName() const override { return "MD5"; } +}; + +#endif // MD5CONVERTER_HPP diff --git a/others/C++/text converter/include/MainWindow.hpp b/others/C++/text converter/include/MainWindow.hpp new file mode 100644 index 0000000..f548bee --- /dev/null +++ b/others/C++/text converter/include/MainWindow.hpp @@ -0,0 +1,26 @@ +#ifndef MAINWINDOW_HPP +#define MAINWINDOW_HPP + +#include +#include +#include +#include +#include +#include + +class MainWindow : public Fl_Window { +public: + MainWindow(int w, int h, const char* title); + ~MainWindow(); + +private: + Fl_Input* inputText; + Fl_Output* outputText; + Fl_Choice* conversionType; + Fl_Button* convertButton; + + static void ConvertCallback(Fl_Widget* widget, void* data); + void ConvertText(); +}; + +#endif // MAINWINDOW_HPP diff --git a/others/C++/text converter/include/ROT13Converter.hpp b/others/C++/text converter/include/ROT13Converter.hpp new file mode 100644 index 0000000..8833efb --- /dev/null +++ b/others/C++/text converter/include/ROT13Converter.hpp @@ -0,0 +1,14 @@ +#ifndef ROT13CONVERTER_HPP +#define ROT13CONVERTER_HPP + +#include "Converter.hpp" +#include +#include + +class ROT13Converter : public Converter { +public: + std::string convert(const std::string& input) override; + std::string getName() const override { return "ROT13"; } +}; + +#endif // ROT13CONVERTER_HPP diff --git a/others/C++/text converter/include/SHA1Converter.hpp b/others/C++/text converter/include/SHA1Converter.hpp new file mode 100644 index 0000000..567e1e7 --- /dev/null +++ b/others/C++/text converter/include/SHA1Converter.hpp @@ -0,0 +1,13 @@ +#ifndef SHA1CONVERTER_HPP +#define SHA1CONVERTER_HPP + +#include "Converter.hpp" +#include + +class SHA1Converter : public Converter { +public: + std::string convert(const std::string& input) override; + std::string getName() const override { return "SHA1"; } +}; + +#endif // SHA1CONVERTER_HPP diff --git a/others/C++/text converter/include/SHA256Converter.hpp b/others/C++/text converter/include/SHA256Converter.hpp new file mode 100644 index 0000000..a022ec2 --- /dev/null +++ b/others/C++/text converter/include/SHA256Converter.hpp @@ -0,0 +1,13 @@ +#ifndef SHA256CONVERTER_HPP +#define SHA256CONVERTER_HPP + +#include "Converter.hpp" +#include + +class SHA256Converter : public Converter { +public: + std::string convert(const std::string& input) override; + std::string getName() const override { return "SHA256"; } +}; + +#endif // SHA256CONVERTER_HPP diff --git a/others/C++/text converter/include/Utils.hpp b/others/C++/text converter/include/Utils.hpp new file mode 100644 index 0000000..b4eb649 --- /dev/null +++ b/others/C++/text converter/include/Utils.hpp @@ -0,0 +1,14 @@ +#ifndef UTILS_HPP +#define UTILS_HPP + +#include +#include "Converter.hpp" +#include "BinaryConverter.hpp" +#include "HexConverter.hpp" + +class Utils { +public: + static std::unique_ptr createConverter(int type); +}; + +#endif // UTILS_HPP diff --git a/others/C++/text converter/src/Ascii85Converter.cpp b/others/C++/text converter/src/Ascii85Converter.cpp new file mode 100644 index 0000000..8245f32 --- /dev/null +++ b/others/C++/text converter/src/Ascii85Converter.cpp @@ -0,0 +1,47 @@ +#include "../include/Ascii85Converter.hpp" +#include +#include +#include +#include + +const std::string ASCII85_PREFIX = "<~"; +const std::string ASCII85_SUFFIX = "~>"; + +std::string Ascii85Converter::convert(const std::string& input) { + std::stringstream result; + result << ASCII85_PREFIX; + + size_t i = 0; + while (i < input.size()) { + uint32_t value = 0; + int bytes = 0; + + // 读取4个字节 + for (int j = 0; j < 4 && (i + j) < input.size(); j++) { + value = (value << 8) | static_cast(input[i + j]); + bytes++; + } + i += bytes; + + // 特殊处理全0的4字节 + if (value == 0 && bytes == 4) { + result << 'z'; + continue; + } + + // 转换为Ascii85 + char chars[5]; + for (int j = 4; j >= 0; j--) { + chars[j] = value % 85 + '!'; + value /= 85; + } + + // 写入结果(只写入bytes+1个字符) + for (int j = 0; j < bytes + 1; j++) { + result << chars[j]; + } + } + + result << ASCII85_SUFFIX; + return result.str(); +} diff --git a/others/C++/text converter/src/Base32Converter.cpp b/others/C++/text converter/src/Base32Converter.cpp new file mode 100644 index 0000000..2feb5ff --- /dev/null +++ b/others/C++/text converter/src/Base32Converter.cpp @@ -0,0 +1,37 @@ +#include "../include/Base32Converter.hpp" +#include +#include + +const std::string BASE32_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; + +std::string Base32Converter::convert(const std::string& input) { + std::string result; + int buffer = 0; + int bitsLeft = 0; + int count = 0; + + for (unsigned char c : input) { + buffer <<= 8; + buffer |= c; + bitsLeft += 8; + count++; + + while (bitsLeft >= 5) { + int index = (buffer >> (bitsLeft - 5)) & 0x1F; + result += BASE32_CHARS[index]; + bitsLeft -= 5; + } + } + + if (bitsLeft > 0) { + int index = (buffer << (5 - bitsLeft)) & 0x1F; + result += BASE32_CHARS[index]; + } + + // 添加填充字符 + while (result.size() % 8 != 0) { + result += '='; + } + + return result; +} diff --git a/others/C++/text converter/src/Base64Converter.cpp b/others/C++/text converter/src/Base64Converter.cpp new file mode 100644 index 0000000..bb57586 --- /dev/null +++ b/others/C++/text converter/src/Base64Converter.cpp @@ -0,0 +1,22 @@ +#include "../include/Base64Converter.hpp" +#include +#include +#include + +std::string Base64Converter::convert(const std::string& input) { + // Base64编码 + BIO *b64 = BIO_new(BIO_f_base64()); + BIO *bio = BIO_new(BIO_s_mem()); + BIO_push(b64, bio); + BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL); + + BIO_write(b64, input.c_str(), input.length()); + BIO_flush(b64); + + char* buffer; + long length = BIO_get_mem_data(bio, &buffer); + std::string result(buffer, length); + + BIO_free_all(b64); + return result; +} diff --git a/others/C++/text converter/src/BinaryConverter.cpp b/others/C++/text converter/src/BinaryConverter.cpp new file mode 100644 index 0000000..6ea5020 --- /dev/null +++ b/others/C++/text converter/src/BinaryConverter.cpp @@ -0,0 +1,27 @@ +#include "../include/BinaryConverter.hpp" +#include +#include +#include + +std::string BinaryConverter::convert(const std::string& input) { + if (input.empty()) { + return ""; + } + + std::stringstream result; + for (char c : input) { + std::string binary = std::bitset<8>(c).to_string(); + // 去除前导0,保留后6位 + size_t firstOne = binary.find('1'); + if (firstOne != std::string::npos) { + binary = binary.substr(firstOne); + } + result << binary << " "; + } + + std::string output = result.str(); + if (!output.empty()) { + output.pop_back(); // 移除最后一个空格 + } + return output; +} diff --git a/others/C++/text converter/src/CRC32Converter.cpp b/others/C++/text converter/src/CRC32Converter.cpp new file mode 100644 index 0000000..cc91010 --- /dev/null +++ b/others/C++/text converter/src/CRC32Converter.cpp @@ -0,0 +1,28 @@ +#include "../include/CRC32Converter.hpp" +#include +#include +#include +#include + +// CRC32多项式 +const uint32_t CRC32_POLY = 0xEDB88320; + +uint32_t computeCRC32(const std::string& input) { + uint32_t crc = 0xFFFFFFFF; + + for (char c : input) { + crc ^= static_cast(c); + for (int i = 0; i < 8; i++) { + crc = (crc >> 1) ^ ((crc & 1) ? CRC32_POLY : 0); + } + } + + return ~crc; +} + +std::string CRC32Converter::convert(const std::string& input) { + uint32_t crc = computeCRC32(input); + std::stringstream ss; + ss << std::hex << std::setw(8) << std::setfill('0') << crc; + return ss.str(); +} diff --git a/others/C++/text converter/src/HexConverter.cpp b/others/C++/text converter/src/HexConverter.cpp new file mode 100644 index 0000000..3b9a959 --- /dev/null +++ b/others/C++/text converter/src/HexConverter.cpp @@ -0,0 +1,23 @@ +#include "../include/HexConverter.hpp" +#include +#include + +std::string HexConverter::convert(const std::string& input) { + if (input.empty()) { + return ""; + } + + std::stringstream result; + for (char c : input) { + result << std::hex << std::setw(2) << std::setfill('0') + << static_cast(static_cast(c)) << " "; + } + + std::string output = result.str(); + // 移除最后一个空格 + if (!output.empty()) { + output.pop_back(); + } + + return output; +} diff --git a/others/C++/text converter/src/MD5Converter.cpp b/others/C++/text converter/src/MD5Converter.cpp new file mode 100644 index 0000000..2e062fd --- /dev/null +++ b/others/C++/text converter/src/MD5Converter.cpp @@ -0,0 +1,23 @@ +#include "../include/MD5Converter.hpp" +#include +#include +#include + +std::string MD5Converter::convert(const std::string& input) { + EVP_MD_CTX* mdctx = EVP_MD_CTX_new(); + const EVP_MD* md = EVP_md5(); + unsigned char digest[EVP_MAX_MD_SIZE]; + unsigned int digest_len; + + EVP_DigestInit_ex(mdctx, md, nullptr); + EVP_DigestUpdate(mdctx, input.c_str(), input.length()); + EVP_DigestFinal_ex(mdctx, digest, &digest_len); + EVP_MD_CTX_free(mdctx); + + std::stringstream ss; + for(unsigned int i = 0; i < digest_len; i++) { + ss << std::hex << std::setw(2) << std::setfill('0') << (int)digest[i]; + } + + return ss.str(); +} diff --git a/others/C++/text converter/src/Main.cpp b/others/C++/text converter/src/Main.cpp new file mode 100644 index 0000000..7df25d2 --- /dev/null +++ b/others/C++/text converter/src/Main.cpp @@ -0,0 +1,14 @@ +#include "../include/MainWindow.hpp" +#include "../include/Config.hpp" +#include + +int main(int argc, char **argv) { + // 创建主窗口 + MainWindow window(Config::WINDOW_WIDTH, Config::WINDOW_HEIGHT, Config::WINDOW_TITLE); + + // 显示窗口 + window.show(argc, argv); + + // 运行FLTK主循环 + return Fl::run(); +} diff --git a/others/C++/text converter/src/MainWindow.cpp b/others/C++/text converter/src/MainWindow.cpp new file mode 100644 index 0000000..571a348 --- /dev/null +++ b/others/C++/text converter/src/MainWindow.cpp @@ -0,0 +1,66 @@ +#include "../include/MainWindow.hpp" +#include "../include/Utils.hpp" +#include "../include/Config.hpp" +#include +#include + +MainWindow::MainWindow(int w, int h, const char* title) : Fl_Window(w, h, title) { + // 初始化UI元素 + inputText = new Fl_Input(Config::INPUT_X, Config::INPUT_Y, + Config::INPUT_WIDTH, Config::INPUT_HEIGHT, "输入文本:"); + outputText = new Fl_Output(Config::OUTPUT_X, Config::OUTPUT_Y, + Config::OUTPUT_WIDTH, Config::OUTPUT_HEIGHT, "输出结果:"); + conversionType = new Fl_Choice(Config::CHOICE_X, Config::CHOICE_Y, + Config::CHOICE_WIDTH, Config::CHOICE_HEIGHT, "转换类型:"); + convertButton = new Fl_Button(Config::BUTTON_X, Config::BUTTON_Y, + Config::BUTTON_WIDTH, Config::BUTTON_HEIGHT, "转换"); + + // 设置转换类型选项 + conversionType->add("二进制"); + conversionType->add("十六进制"); + conversionType->add("ROT13"); + conversionType->add("MD5"); + conversionType->add("SHA1"); + conversionType->add("SHA256"); + conversionType->add("Base64"); + conversionType->add("Base32"); + conversionType->add("Ascii85"); + conversionType->add("CRC32"); + conversionType->value(0); // 默认选择二进制 + + // 设置按钮回调 + convertButton->callback(ConvertCallback, this); + + end(); // 结束窗口组件添加 +} + +MainWindow::~MainWindow() { + // 清理资源 + delete inputText; + delete outputText; + delete conversionType; + delete convertButton; +} + +void MainWindow::ConvertCallback(Fl_Widget* widget, void* data) { + MainWindow* window = static_cast(data); + window->ConvertText(); +} + +void MainWindow::ConvertText() { + const char* input = inputText->value(); + if (!input || strlen(input) == 0) { + fl_alert("请输入要转换的文本"); + return; + } + + int type = conversionType->value(); + auto converter = Utils::createConverter(type); + if (!converter) { + fl_alert("不支持的转换类型"); + return; + } + + std::string result = converter->convert(input); + outputText->value(result.c_str()); +} diff --git a/others/C++/text converter/src/ROT13Converter.cpp b/others/C++/text converter/src/ROT13Converter.cpp new file mode 100644 index 0000000..ebd9252 --- /dev/null +++ b/others/C++/text converter/src/ROT13Converter.cpp @@ -0,0 +1,13 @@ +#include "../include/ROT13Converter.hpp" + +std::string ROT13Converter::convert(const std::string& input) { + std::string result; + for (char c : input) { + if (isalpha(c)) { + char base = isupper(c) ? 'A' : 'a'; + c = (c - base + 13) % 26 + base; + } + result += c; + } + return result; +} diff --git a/others/C++/text converter/src/SHA1Converter.cpp b/others/C++/text converter/src/SHA1Converter.cpp new file mode 100644 index 0000000..9ae55ee --- /dev/null +++ b/others/C++/text converter/src/SHA1Converter.cpp @@ -0,0 +1,23 @@ +#include "../include/SHA1Converter.hpp" +#include +#include +#include + +std::string SHA1Converter::convert(const std::string& input) { + EVP_MD_CTX* mdctx = EVP_MD_CTX_new(); + const EVP_MD* md = EVP_sha1(); + unsigned char digest[EVP_MAX_MD_SIZE]; + unsigned int digest_len; + + EVP_DigestInit_ex(mdctx, md, nullptr); + EVP_DigestUpdate(mdctx, input.c_str(), input.length()); + EVP_DigestFinal_ex(mdctx, digest, &digest_len); + EVP_MD_CTX_free(mdctx); + + std::stringstream ss; + for(unsigned int i = 0; i < digest_len; i++) { + ss << std::hex << std::setw(2) << std::setfill('0') << (int)digest[i]; + } + + return ss.str(); +} \ No newline at end of file diff --git a/others/C++/text converter/src/SHA256Converter.cpp b/others/C++/text converter/src/SHA256Converter.cpp new file mode 100644 index 0000000..f963653 --- /dev/null +++ b/others/C++/text converter/src/SHA256Converter.cpp @@ -0,0 +1,23 @@ +#include "../include/SHA256Converter.hpp" +#include +#include +#include + +std::string SHA256Converter::convert(const std::string& input) { + EVP_MD_CTX* mdctx = EVP_MD_CTX_new(); + const EVP_MD* md = EVP_sha256(); + unsigned char digest[EVP_MAX_MD_SIZE]; + unsigned int digest_len; + + EVP_DigestInit_ex(mdctx, md, nullptr); + EVP_DigestUpdate(mdctx, input.c_str(), input.length()); + EVP_DigestFinal_ex(mdctx, digest, &digest_len); + EVP_MD_CTX_free(mdctx); + + std::stringstream ss; + for(unsigned int i = 0; i < digest_len; i++) { + ss << std::hex << std::setw(2) << std::setfill('0') << (int)digest[i]; + } + + return ss.str(); +} diff --git a/others/C++/text converter/src/Utils.cpp b/others/C++/text converter/src/Utils.cpp new file mode 100644 index 0000000..a77739f --- /dev/null +++ b/others/C++/text converter/src/Utils.cpp @@ -0,0 +1,25 @@ +#include "../include/Utils.hpp" +#include "../include/ROT13Converter.hpp" +#include "../include/MD5Converter.hpp" +#include "../include/SHA1Converter.hpp" +#include "../include/SHA256Converter.hpp" +#include "../include/Base64Converter.hpp" +#include "../include/Base32Converter.hpp" +#include "../include/Ascii85Converter.hpp" +#include "../include/CRC32Converter.hpp" + +std::unique_ptr Utils::createConverter(int type) { + switch (type) { + case 0: return std::unique_ptr(new BinaryConverter()); + case 1: return std::unique_ptr(new HexConverter()); + case 2: return std::unique_ptr(new ROT13Converter()); + case 3: return std::unique_ptr(new MD5Converter()); + case 4: return std::unique_ptr(new SHA1Converter()); + case 5: return std::unique_ptr(new SHA256Converter()); + case 6: return std::unique_ptr(new Base64Converter()); + case 7: return std::unique_ptr(new Base32Converter()); + case 8: return std::unique_ptr(new Ascii85Converter()); + case 9: return std::unique_ptr(new CRC32Converter()); + default: return nullptr; + } +}