mirror of
https://github.com/zs-yg/kortapp-z.git
synced 2025-12-06 16:10:42 +08:00
Add files via upload
This commit is contained in:
@@ -9,7 +9,7 @@ public:
|
||||
static std::string getVersion() { return "1.0.0"; }
|
||||
static std::string getAuthor() { return "zsyg"; }
|
||||
static std::string getDescription() {
|
||||
return "一个简单的文本转换工具,支持文本转换";
|
||||
return "一个简单的文本转换工具,支持文本转换";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -5,18 +5,6 @@
|
||||
#include "Converter.hpp"
|
||||
#include "BinaryConverter.hpp"
|
||||
#include "HexConverter.hpp"
|
||||
#include "ROT13Converter.hpp"
|
||||
#include "MD5Converter.hpp"
|
||||
#include "SHA1Converter.hpp"
|
||||
#include "SHA256Converter.hpp"
|
||||
#include "SHA224Converter.hpp"
|
||||
#include "SHA384Converter.hpp"
|
||||
#include "SHA512Converter.hpp"
|
||||
#include "SHA3Converter.hpp"
|
||||
#include "Base64Converter.hpp"
|
||||
#include "Base32Converter.hpp"
|
||||
#include "Ascii85Converter.hpp"
|
||||
#include "CRC32Converter.hpp"
|
||||
|
||||
class Utils {
|
||||
public:
|
||||
|
||||
@@ -11,7 +11,7 @@ std::string BinaryConverter::convert(const std::string& input) {
|
||||
std::stringstream result;
|
||||
for (char c : input) {
|
||||
std::string binary = std::bitset<8>(c).to_string();
|
||||
// 去除前导0,保留后6位
|
||||
// 去除前导0,保留后6位
|
||||
size_t firstOne = binary.find('1');
|
||||
if (firstOne != std::string::npos) {
|
||||
binary = binary.substr(firstOne);
|
||||
|
||||
@@ -22,10 +22,6 @@ MainWindow::MainWindow(int w, int h, const char* title) : Fl_Window(w, h, title)
|
||||
conversionType->add("MD5");
|
||||
conversionType->add("SHA1");
|
||||
conversionType->add("SHA256");
|
||||
conversionType->add("SHA224");
|
||||
conversionType->add("SHA384");
|
||||
conversionType->add("SHA512");
|
||||
conversionType->add("SHA3");
|
||||
conversionType->add("Base64");
|
||||
conversionType->add("Base32");
|
||||
conversionType->add("Ascii85");
|
||||
@@ -52,25 +48,19 @@ void MainWindow::ConvertCallback(Fl_Widget* widget, void* data) {
|
||||
}
|
||||
|
||||
void MainWindow::ConvertText() {
|
||||
try {
|
||||
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());
|
||||
} catch (const std::exception& e) {
|
||||
fl_alert(("转换失败: " + std::string(e.what())).c_str());
|
||||
} catch (...) {
|
||||
fl_alert("未知错误: 转换失败");
|
||||
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());
|
||||
}
|
||||
|
||||
@@ -3,10 +3,6 @@
|
||||
#include "../include/MD5Converter.hpp"
|
||||
#include "../include/SHA1Converter.hpp"
|
||||
#include "../include/SHA256Converter.hpp"
|
||||
#include "../include/SHA224Converter.hpp"
|
||||
#include "../include/SHA384Converter.hpp"
|
||||
#include "../include/SHA512Converter.hpp"
|
||||
#include "../include/SHA3Converter.hpp"
|
||||
#include "../include/Base64Converter.hpp"
|
||||
#include "../include/Base32Converter.hpp"
|
||||
#include "../include/Ascii85Converter.hpp"
|
||||
@@ -24,10 +20,6 @@ std::unique_ptr<Converter> Utils::createConverter(int type) {
|
||||
case 7: return std::unique_ptr<Converter>(new Base32Converter());
|
||||
case 8: return std::unique_ptr<Converter>(new Ascii85Converter());
|
||||
case 9: return std::unique_ptr<Converter>(new CRC32Converter());
|
||||
case 10: return std::unique_ptr<Converter>(new SHA224Converter());
|
||||
case 11: return std::unique_ptr<Converter>(new SHA384Converter());
|
||||
case 12: return std::unique_ptr<Converter>(new SHA512Converter());
|
||||
case 13: return std::unique_ptr<Converter>(new SHA3Converter());
|
||||
default: return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user