Update: drop Qt dependency, rewrite as pure Win32 using v142 toolset. Replace Update.ui/qrc and miniz-based Zip with Api/Crypto/Http/Json/Unzip/UpdateWindow modules. CrownClient/CrownServer: update Verify and main sources, retarget x64 configs to v142 (VS2019) with SDK 10.0.19041.0, fix VMProtect SDK paths.
34 lines
1.1 KiB
C++
34 lines
1.1 KiB
C++
#pragma once
|
||
|
||
#include <string>
|
||
#include <vector>
|
||
|
||
namespace updater {
|
||
|
||
enum class EncryptType {
|
||
None = 0,
|
||
RC4 = 1,
|
||
AES = 2, // AES-256-GCM:12 字节 nonce 前置 + 16 字节 tag
|
||
};
|
||
|
||
class Crypto {
|
||
public:
|
||
// 与 Go 端 crypto.padKey 保持一致:不足 target 时循环补齐,超出则截断
|
||
static std::vector<unsigned char> PadKey(const std::vector<unsigned char>& key, size_t target);
|
||
|
||
static bool Base64Decode(const std::string& input, std::vector<unsigned char>& out);
|
||
static std::string Base64Encode(const std::vector<unsigned char>& input);
|
||
|
||
// ciphertext 为 base64 字符串,out 为解密后的明文
|
||
static bool Decrypt(EncryptType type, const std::string& key, const std::string& ciphertext,
|
||
std::string& out, std::string& err);
|
||
|
||
private:
|
||
static bool DecryptAes(const std::string& key, const std::string& ciphertext, std::string& out,
|
||
std::string& err);
|
||
static bool DecryptRc4(const std::string& key, const std::string& ciphertext, std::string& out,
|
||
std::string& err);
|
||
};
|
||
|
||
}
|