From ae78cc98a85b362499f3486fd5b387b3c8a1b0e5 Mon Sep 17 00:00:00 2001 From: taynpg Date: Tue, 29 Oct 2024 21:19:18 +0800 Subject: [PATCH] =?UTF-8?q?add=EF=BC=9A=E6=B7=BB=E5=8A=A0=E4=B8=A4?= =?UTF-8?q?=E4=B8=AA=E6=A8=A1=E6=9D=BFbase64=E5=86=85=E5=AE=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 3 ++- CMakeLists.txt | 1 + install.cpp | 3 +++ main.cpp | 2 ++ resource.cpp | 52 +++++++++++++++++++++++++++++++++++++++++++ resource.h | 15 +++++++++++++ 6 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 resource.cpp create mode 100644 resource.h diff --git a/.vscode/settings.json b/.vscode/settings.json index 1ec6b1a..2a48940 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -17,7 +17,8 @@ } ], "args": [ - "-m", "0", "-f", "/home/yun/Code/PackBinary/build/PackBinary", "-p", "/home/yun/文档", "-d", "/home/yun/mlib/boost/lib" + "-m", "1", "-f", "/home/yun/Code/PackBinary/build/PackBinary", "-p", "/home/yun/文档", "-d", "/home/yun/mlib/boost/lib", + "-i", "/home/yun/Code/PackBinary/build/PackBinary" ] }, // "cmake.configureSettings": { diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f5f1a1..faef521 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,7 @@ set(SOURCES_FILE cmd_parse.cpp public.hpp pack.h pack.cpp install.h install.cpp + resource.h resource.cpp ) set(Boost_USE_STATIC_LIBS OFF) diff --git a/install.cpp b/install.cpp index a439622..79e5b0d 100644 --- a/install.cpp +++ b/install.cpp @@ -1,6 +1,9 @@ #include "install.h" +#include "resource.h" bool CInstallBinary::startInstall(const CmdResult& result) { + CResource res; + auto shell_template = res.getShellTemplate(); return false; } \ No newline at end of file diff --git a/main.cpp b/main.cpp index bfa2b18..6678137 100644 --- a/main.cpp +++ b/main.cpp @@ -13,7 +13,9 @@ int main(int argc, char** argv) return 0; } if (!parse.Run()) { + std::cout << "\n功能执行失败。" << std::endl; return 0; } + std::cout << "\n完成。" << std::endl; return 0; } diff --git a/resource.cpp b/resource.cpp new file mode 100644 index 0000000..a2e3cdc --- /dev/null +++ b/resource.cpp @@ -0,0 +1,52 @@ +#include "resource.h" +#include +#include +#include + +CResource::CResource() +{ +} + +std::string base64_decode(const std::string& in) +{ + static const std::string base64_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789+/"; + + std::string out; + int val = 0, valb = -8; + for (unsigned char c : in) { + if (base64_chars.find(c) == std::string::npos) { + if (c != '=') { + std::cout << "Invalid Base64 input" << std::endl; + } + continue; + } + val = (val << 6) + base64_chars.find(c); + valb += 6; + if (valb >= 0) { + out.push_back(char((val >> valb) & 0xFF)); + valb -= 8; + } + } + return out; +} + +std::string CResource::getShellTemplate() +{ + std::string s = + "IyEvYmluL2Jhc2gKU0NSSVBUX0RJUj0kKGNkICIkKGRpcm5hbWUgIiQwIikiICYmIHB3ZC" + "kKY2QgIiRTQ1JJUFRfRElSIiB8fCBleGl0CmV4cG9ydCBMRF9MSUJSQVJZX1BBVEg9JExE" + "X0xJQlJBUllfUEFUSDoiJFNDUklQVF9ESVIiCiIkU0NSSVBUX0RJUi9yZXBsYWNlX3N0ci" + "IgIiRAIgo="; + return base64_decode(s); +} + +std::string CResource::getDesktopTemplate() +{ + std::string s = + "W0Rlc2t0b3AgRW50cnldCk5hbWU9cmVfbmFtZQpDb21tZW50PXJlX2Rlc2NyaWJlCkV4ZW" + "M9cmVfcGF0aApJY29uPXJlX2ljb24KVGVybWluYWw9ZmFsc2UKVHlwZT1BcHBsaWNhdGlv" + "bgpDYXRlZ29yaWVzPXJlX2NhdGVnb3J5Owo="; + return base64_decode(s); +} diff --git a/resource.h b/resource.h new file mode 100644 index 0000000..ec6db43 --- /dev/null +++ b/resource.h @@ -0,0 +1,15 @@ +#ifndef RESOURCE_HEADER +#define RESOURCE_HEADER + +#include + +class CResource +{ +public: + CResource(); +public: + std::string getShellTemplate(); + std::string getDesktopTemplate(); +}; + +#endif \ No newline at end of file