modify valid failed
This commit is contained in:
parent
0e7f56cf7c
commit
5f24feea2b
@ -44,8 +44,8 @@ add_executable(generate_valid src/generate_valid.cpp)
|
|||||||
target_link_libraries(generate_valid PRIVATE RegistrationDLL)
|
target_link_libraries(generate_valid PRIVATE RegistrationDLL)
|
||||||
|
|
||||||
# --- 生成有效许可证文件程序 ---
|
# --- 生成有效许可证文件程序 ---
|
||||||
add_executable(generate_valid src/generate_valid.cpp)
|
add_executable(test_encryption src/test_encryption.cpp)
|
||||||
target_link_libraries(generate_valid PRIVATE RegistrationDLL)
|
target_link_libraries(test_encryption PRIVATE RegistrationDLL)
|
||||||
|
|
||||||
# 将生成的文件输出到 build/bin 目录
|
# 将生成的文件输出到 build/bin 目录
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||||
|
|||||||
@ -101,7 +101,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
|
|||||||
// --- Middle Part: Decryption ---
|
// --- 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", "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);
|
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("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);
|
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);
|
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];
|
char encryptedCode[64];
|
||||||
GetWindowText(hDecInputEdit, encryptedCode, sizeof(encryptedCode));
|
GetWindowText(hDecInputEdit, encryptedCode, sizeof(encryptedCode));
|
||||||
int len = strlen(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);
|
MessageBox(hwnd, "Please enter a valid 32-character encrypted code.", "Error", MB_ICONERROR);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -148,5 +148,5 @@ std::string getMachineCode() {
|
|||||||
macAddress.erase(std::remove_if(macAddress.begin(), macAddress.end(), isspace), macAddress.end());
|
macAddress.erase(std::remove_if(macAddress.begin(), macAddress.end(), isspace), macAddress.end());
|
||||||
macAddress.erase(std::remove(macAddress.begin(), macAddress.end(), ':'), macAddress.end());
|
macAddress.erase(std::remove(macAddress.begin(), macAddress.end(), ':'), macAddress.end());
|
||||||
|
|
||||||
return cpuId + "-" + macAddress;
|
return cpuId + macAddress;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,14 +30,14 @@ int main(int argc, char* argv[]) {
|
|||||||
std::cout << "Generating license with expiration date: " << future_date << std::endl;
|
std::cout << "Generating license with expiration date: " << future_date << std::endl;
|
||||||
char code[33] = { 0 };
|
char code[33] = { 0 };
|
||||||
DecryptCodeAndGetMachineCode(machine_code, code, 33);
|
DecryptCodeAndGetMachineCode(machine_code, code, 33);
|
||||||
int gen_result = GenerateLicenseFileFromCode(code, future_date);
|
/*int gen_result = GenerateLicenseFileFromCode(code, future_date);
|
||||||
if (gen_result == 0) {
|
if (gen_result == 0) {
|
||||||
std::cout << "License.data generated successfully." << std::endl;
|
std::cout << "License.data generated successfully." << std::endl;
|
||||||
} else {
|
} else {
|
||||||
std::cout << "!! ERROR: Failed to generate License.data." << std::endl;
|
std::cout << "!! ERROR: Failed to generate License.data." << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;*/
|
||||||
|
|
||||||
// --- Step 2: Validate the generated file ---
|
// --- Step 2: Validate the generated file ---
|
||||||
std::cout << "--- Step 2: Validating the newly created License.data file ---" << std::endl;
|
std::cout << "--- Step 2: Validating the newly created License.data file ---" << std::endl;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user