GrabBag/Module/AuthModule/Inc/AuthManager.h
2026-01-25 01:27:01 +08:00

44 lines
1.6 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef AUTHMANAGER_H
#define AUTHMANAGER_H
#include <string>
#include <ctime>
class AuthManager
{
public:
// 获取机器码
static std::string GetMachineCode();
// 生成授权码带过期时间格式yyyyMMdd
static std::string GenerateLicenseKey(const std::string& machineCode, const std::string& expireDate);
// 保存授权信息
static bool SaveLicenseInfo(const std::string& licenseKey, const std::string& expireDate);
// 加载授权信息
static bool LoadLicenseInfo(std::string& licenseKey, std::string& expireDate);
// 检查授权有效性
static bool CheckLicenseValid();
// 验证用户输入的授权码,返回是否有效及过期日期
static bool ValidateLicenseKey(const std::string& licenseKey, std::string& expireDate);
private:
static std::string GetCpuSerialNumber();
static std::string GetDiskSerialNumber();
static std::string ExecuteCommand(const std::string& cmd);
static std::string MD5Hash(const std::string& input);
static std::string EncryptString(const std::string& plainText, const std::string& key);
static std::string DecryptString(const std::string& cipherText, const std::string& key);
static std::string Base64Encode(const std::string& input);
static std::string Base64Decode(const std::string& input);
static std::string GetCurrentDate();
static std::string GetCurrentDateTime();
static std::string ToUpper(const std::string& str);
static std::string GetFilePath();
};
#endif // AUTHMANAGER_H