59 lines
1.2 KiB
C
59 lines
1.2 KiB
C
|
#pragma once
|
||
|
#include <curl/curl.h>
|
||
|
#include <string>
|
||
|
#include <openssl/evp.h>
|
||
|
#include <openssl/err.h>
|
||
|
|
||
|
class CHttpsHandle
|
||
|
{
|
||
|
public:
|
||
|
CHttpsHandle();
|
||
|
~CHttpsHandle();
|
||
|
public:
|
||
|
std::string sendGetRequest(const std::string& url);
|
||
|
private:
|
||
|
static size_t WriteCallback(void* contents, size_t size, size_t nmemb, void* userp);
|
||
|
private:
|
||
|
CURL* curl{};
|
||
|
};
|
||
|
|
||
|
class CUtil
|
||
|
{
|
||
|
public:
|
||
|
CUtil() = default;
|
||
|
~CUtil() = default;
|
||
|
public:
|
||
|
static std::string generateMD5(const std::string& input);
|
||
|
static std::string generateRandomNumStr();
|
||
|
static std::string urlEncode(const std::string& str);
|
||
|
};
|
||
|
|
||
|
using str_t = std::string;
|
||
|
class CTransTool
|
||
|
{
|
||
|
public:
|
||
|
CTransTool() = default;
|
||
|
~CTransTool() = default;
|
||
|
public:
|
||
|
void set_id(const str_t& id, const str_t& secret_key);
|
||
|
std::string combine(const str_t& words, const str_t& from, const str_t& to);
|
||
|
private:
|
||
|
std::string appid_{};
|
||
|
std::string secret_key_{};
|
||
|
};
|
||
|
|
||
|
|
||
|
struct ConfigInfo {
|
||
|
std::string baseUrl;
|
||
|
std::string appID;
|
||
|
std::string secretID;
|
||
|
};
|
||
|
|
||
|
class CConfig
|
||
|
{
|
||
|
public:
|
||
|
CConfig() = default;
|
||
|
~CConfig() = default;
|
||
|
public:
|
||
|
bool parse_config(ConfigInfo& config, const std::string& config_path = "");
|
||
|
};
|