diff --git a/CMakeLists.txt b/CMakeLists.txt index e101f20..a988ab2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,8 +44,8 @@ add_executable(generate_valid src/generate_valid.cpp) target_link_libraries(generate_valid PRIVATE RegistrationDLL) # --- 生成有效许可证文件程序 --- -add_executable(generate_valid src/generate_valid.cpp) -target_link_libraries(generate_valid PRIVATE RegistrationDLL) +add_executable(test_encryption src/test_encryption.cpp) +target_link_libraries(test_encryption PRIVATE RegistrationDLL) # 将生成的文件输出到 build/bin 目录 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) diff --git a/src/gui.cpp b/src/gui.cpp index 3627638..19059a2 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -101,7 +101,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { // --- Middle Part: Decryption --- CreateWindow("STATIC", "Decrypt Encrypted Code", WS_VISIBLE | WS_CHILD | BS_GROUPBOX, 10, 50, 460, 120, hwnd, (HMENU)IDC_DEC_GROUP, NULL, NULL); CreateWindow("STATIC", "Encrypted Code:", WS_VISIBLE | WS_CHILD, 30, 80, 150, 20, hwnd, (HMENU)IDC_DEC_INPUT_LABEL, NULL, NULL); - hDecInputEdit = CreateWindow("EDIT", "", WS_VISIBLE | WS_CHILD | WS_BORDER, 190, 80, 260, 20, hwnd, (HMENU)IDC_DEC_INPUT_EDIT, NULL, NULL); + hDecInputEdit = CreateWindow("EDIT", "", WS_VISIBLE | WS_CHILD | WS_BORDER, 190, 80, 270, 20, hwnd, (HMENU)IDC_DEC_INPUT_EDIT, NULL, NULL); CreateWindow("BUTTON", "Decrypt", WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, 190, 110, 120, 30, hwnd, (HMENU)IDC_DEC_BUTTON, NULL, NULL); CreateWindow("STATIC", "Original Machine Code:", WS_VISIBLE | WS_CHILD, 30, 145, 150, 20, hwnd, (HMENU)IDC_DEC_OUTPUT_LABEL, NULL, NULL); hDecOutputEdit = CreateWindow("EDIT", "", WS_VISIBLE | WS_CHILD | WS_BORDER | ES_READONLY, 190, 145, 260, 20, hwnd, (HMENU)IDC_DEC_OUTPUT_EDIT, NULL, NULL); @@ -142,7 +142,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { char encryptedCode[64]; GetWindowText(hDecInputEdit, encryptedCode, sizeof(encryptedCode)); int len = strlen(encryptedCode); - if (strlen(encryptedCode) != 30) { + if (strlen(encryptedCode) != 32) { MessageBox(hwnd, "Please enter a valid 32-character encrypted code.", "Error", MB_ICONERROR); break; } diff --git a/src/machine_code.cpp b/src/machine_code.cpp index c93dd70..8b2b3d4 100644 --- a/src/machine_code.cpp +++ b/src/machine_code.cpp @@ -148,5 +148,5 @@ std::string getMachineCode() { macAddress.erase(std::remove_if(macAddress.begin(), macAddress.end(), isspace), macAddress.end()); macAddress.erase(std::remove(macAddress.begin(), macAddress.end(), ':'), macAddress.end()); - return cpuId + "-" + macAddress; + return cpuId + macAddress; } diff --git a/src/test_license.cpp b/src/test_license.cpp index 38ec535..4eefb1c 100644 --- a/src/test_license.cpp +++ b/src/test_license.cpp @@ -30,14 +30,14 @@ int main(int argc, char* argv[]) { std::cout << "Generating license with expiration date: " << future_date << std::endl; char code[33] = { 0 }; DecryptCodeAndGetMachineCode(machine_code, code, 33); - int gen_result = GenerateLicenseFileFromCode(code, future_date); + /*int gen_result = GenerateLicenseFileFromCode(code, future_date); if (gen_result == 0) { std::cout << "License.data generated successfully." << std::endl; } else { std::cout << "!! ERROR: Failed to generate License.data." << std::endl; return 1; } - std::cout << std::endl; + std::cout << std::endl;*/ // --- Step 2: Validate the generated file --- std::cout << "--- Step 2: Validating the newly created License.data file ---" << std::endl;