navicat_serial_generator.hpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #pragma once
  2. #include <string>
  3. #include <vector>
  4. #include <openssl/des.h>
  5. namespace nkg {
  6. enum class navicat_software_language {
  7. English,
  8. SimplifiedChinese,
  9. TraditionalChinese,
  10. Japanese,
  11. Polish,
  12. Spanish,
  13. French,
  14. German,
  15. Korean,
  16. Russian,
  17. Portuguese
  18. };
  19. enum class navicat_software_type {
  20. DataModeler,
  21. Premium,
  22. MySQL,
  23. PostgreSQL,
  24. Oracle,
  25. SQLServer,
  26. SQLite,
  27. MariaDB,
  28. MongoDB,
  29. ReportViewer
  30. };
  31. class navicat_serial_generator {
  32. private:
  33. static inline const DES_cblock s_des_key0 = { 0x64, 0xAD, 0xF3, 0x2F, 0xAE, 0xF2, 0x1A, 0x27 };
  34. static inline const DES_cblock s_des_key1 = { 0xE9, 0x7F, 0xB0, 0x60, 0x77, 0x45, 0x90, 0xAE };
  35. uint8_t m_data[10];
  36. DES_cblock m_des_key;
  37. std::string m_serial_number;
  38. std::string m_serial_number_formatted;
  39. public:
  40. navicat_serial_generator() noexcept;
  41. void set_software_language(navicat_software_language lang) noexcept;
  42. void set_software_language(uint8_t lang_sig0, uint8_t lang_sig1) noexcept;
  43. void set_software_type(navicat_software_type software_type) noexcept;
  44. void set_software_type(uint8_t software_type_sig) noexcept;
  45. void set_software_version(int Version);
  46. void generate();
  47. [[nodiscard]]
  48. const std::string& serial_number() const noexcept;
  49. [[nodiscard]]
  50. const std::string& serial_number_formatted() const noexcept;
  51. };
  52. }