Authorization.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #pragma once
  2. #include <string>
  3. /**
  4. * @brief 授权管理类
  5. */
  6. class Authorization
  7. {
  8. public:
  9. /**
  10. * @brief 检查授权文件是否有效
  11. * @return true 如果授权有效,false 如果授权无效或不存在
  12. */
  13. static bool IsAuthorized();
  14. /**
  15. * @brief 生成授权码文件
  16. * @param machineCode 机器码
  17. * @return true 如果生成成功,false 如果失败
  18. */
  19. static bool GenerateAuthorizationCodeFile(const std::string &machineCode);
  20. /**
  21. * @brief 获取机器码
  22. * @return 机器码字符串
  23. */
  24. static std::string GetMachineCode();
  25. private:
  26. /**
  27. * @brief 获取CPU ID
  28. * @return CPU ID字符串
  29. */
  30. static std::string GetCPUID();
  31. /**
  32. * @brief 获取硬盘序列号
  33. * @return 硬盘序列号字符串
  34. */
  35. static std::string GetHardDiskSerial();
  36. /**
  37. * @brief 获取MAC地址
  38. * @return MAC地址字符串
  39. */
  40. static std::string GetMACAddress();
  41. /**
  42. * @brief 验证授权文件
  43. * @param licenseFile 授权文件路径
  44. * @return true 如果授权文件有效,false 如果无效
  45. */
  46. static bool VerifyLicenseFile(const std::string &licenseFile);
  47. /**
  48. * @brief 解密授权文件
  49. * @param encryptedData 加密的数据
  50. * @return 解密后的数据
  51. */
  52. static std::string DecryptLicense(const std::string &encryptedData);
  53. /**
  54. * @brief 加密数据
  55. * @param data 要加密的数据
  56. * @return 加密后的数据
  57. */
  58. static std::string EncryptData(const std::string &data);
  59. };