I have a system for controlling and issuing electronic license registration files so that I can control how many machines my software can run. My teacher advised me to use the processor's CPUID to validate and generate a license file (get CPUID
and make a calculation on top of it, so the result would be unique for each processor) and the validation would be done at the time of installation, the requests would be made to the server that would request the CPUID
of the machine and return the license file.
Are there other ways to do this license record control? Is there any API or feature? And how can the implementation be done?
Here's my basic prototype that gets CPUID
and performs a calculation. There are two functions string getCPUID()
and double CalculaCpuId(string cpuid)
is the basis for generating the electronic license record file.
Function getCPUID
:
private string getCPUID()
{
String cpuid = "";
try
{
ManagementObjectSearcher mbs = new ManagementObjectSearcher("Select ProcessorID From Win32_processor");
ManagementObjectCollection mbsList = mbs.Get();
foreach (ManagementObject mo in mbsList)
{
cpuid = mo["ProcessorID"].ToString();
}
return cpuid;
}
catch (Exception) { return cpuid; }
}
Function CalculaCpuId
:
private double CalculaCpuId(string cpuid)
{
if (string.IsNullOrEmpty(cpuid))
return 0;
double resultado = 0;
int soma = 0;
string digito;
for (int i = 0; i < cpuid.Length; i++)
{
digito = cpuid[i].ToString();
soma += Convert.ToInt32(digito, 16);
}
resultado = (soma / ((Math.Pow(2, 2)) + 4));
return resultado;
}
I'm using Visual Studio to develop my system that needs the license record control.