h_sw_registro/include/registration_api.h
2025-08-05 23:32:23 +08:00

49 lines
1.6 KiB
C++

#ifndef REGISTRATION_API_H
#define REGISTRATION_API_H
#ifdef REGISTRATION_EXPORTS
#define REGISTRATION_API __declspec(dllexport)
#else
#define REGISTRATION_API __declspec(dllimport)
#endif
#include <string>
#ifdef __cplusplus
extern "C" {
#endif
// --- Core Functions ---
// Gets the raw machine code.
REGISTRATION_API const char* GetMachineCode();
// Validates the license file.
// @return: 0=success, 1=failure, 2=expired.
REGISTRATION_API int ValidateLicenseFile();
// Generates a license file from a provided machine code.
// @param machine_code: The machine code to use.
// @param expiration_date: A date string in "YYYY-MM-DD" format.
// @return: 0=success, 1=failure.
REGISTRATION_API int GenerateLicenseFileFromCode(const char* machine_code, const char* expiration_date);
// --- New Encryption/Decryption API ---
// Generates a dynamic, 32-character encrypted code from the machine code.
// The returned string is managed by the DLL and should not be freed by the caller.
REGISTRATION_API const char* GenerateEncryptedCode();
// Decrypts a 32-character code to get the original machine code.
// @param encrypted_code: The 32-character hex string to decrypt.
// @param decrypted_machine_code: A buffer to store the null-terminated result.
// @param buffer_size: The size of the provided buffer.
// @return: 0 on success, 1 on failure (e.g., invalid format, bad length).
REGISTRATION_API int DecryptCodeAndGetMachineCode(const char* encrypted_code, char* decrypted_machine_code, int buffer_size);
#ifdef __cplusplus
}
#endif
#endif // REGISTRATION_API_H