I have written a software, in which i will read the CPU-ID and i will display the CPU-ID to the user as a Software Serial Key and it will request for a confirmation key to login to the software. The user has to mail me that CPU-ID (Serial Key) so that i have to generate a confirmation key and send it back to the user to login.
I am using Linux and C
Here is the code i have used to get my CPU-ID
Sample CPU-ID Looks like this : 0103-06A9-0123-0100-8974-4587
I will be thankful if anyone help me to generate a simple encrypted serial number and to generated a confirmation key. Thank you.
Note : If the key is displayed in readable format then it will be better.. i.e, without special characters...
char CPU[30]; //24 Hex digits, PROCESS_SERIAL_NUM
int varEAX, varEBX, varECX, varEDX;
char str[9];
__asm__ __volatile__ ("cpuid" : "=a" (varEAX), "=b" (varEBX), "=c" (varECX), "=d" (varEDX) : "a" (1));
sprintf(str, "%08X", varEAX); //i.e. XXXX-XXXX-xxxx-xxxx-xxxx-xxxx
sprintf(CPU, "%C%C%C%C-%C%C%C%C", str[0], str[1], str[2], str[3], str[4], str[5], str[6], str[7]);
__asm__ __volatile__ ("cpuid" : "=a" (varEAX), "=b" (varEBX), "=c" (varECX), "=d" (varEDX) : "a" (3));
sprintf(str, "%08X", varEDX); //i.e. xxxx-xxxx-XXXX-XXXX-xxxx-xxxx
sprintf(CPU, "%s-%C%C%C%C-%C%C%C%C", CPU, str[0], str[1], str[2], str[3], str[4], str[5], str[6], str[7]);
sprintf(str, "%08X", varECX); //i.e. xxxx-xxxx-xxxx-xxxx-XXXX-XXXX
sprintf(CPU, "%s-%C%C%C%C-%C%C%C%C", CPU, str[0], str[1], str[2], str[3], str[4], str[5], str[6], str[7]);
printf("%s\n", CPU); //compare with: lshw | grep serial: