I will deploy a windows application to some client machines. They will run offline. I need to make sure that they cannot move application to another machines. I am able to build my project for every deployment.
So what I thought is: I write a tool for getting the computers cpuID, encrypt it, embed it into a static variable in my application code, build and deploy it to client. Then on applications start, I will get the cpuID with the application itself this time and decrpyt the encrypted cpuID from that static variable, check if they match and allow or reject the launching of the application. So I will only have the decryption algorithm present in the application code.
I need to make sure that even they reverse engineer the code, they cannot create their own encrypted cpuID's and change that static variable.
I need an encryption system which I guess needs to be an asymmetric one but I'm not sure, and bad intentioned people shouldn't be able to understand the way I encrypt the cpuId by looking at the decryption algorithm.
Is something like this even possible? If it is possible what kind of algorithms they are and can I implement them on my own? Or are there any stable implementations?
EDIT: What I am asking is actually an encrpytion algorithm that is not possible the deduce from its decrpytion algorithm. So the question is not actually about software protection. I just wanted to explain how will I use it.
EDIT2: Here is what I am trying to do.
Hash Tool:
public string GetDeviceHashEncrypted(out RSParameters publicKey)
{
var deviceHash = getComputerHash(); // combination of few things.
using(var rsa = new RSACryptoServiceProvider())
{
publicKey = rsa.ExportParameters(false);
return new UnicodeEncoding().GetString(rsa.Encrypt(deviceHash, false));
}
}
after I get the public key and encrypted data from the hash tool I write them into client apps code manually. And build and deploy it to client.
Client:
public static string EncryptedDeviceHash = ...; //encrypted version of device hash
public static RSAParameters PublicKey = ...; // public key generated by hash tool
...
public bool _validateDevice()
{
var deviceHash = getComputerHash(); // combination of few things.
using(var rsa = new RSACryptoServiceProvider())
{
rsa.ImportParameters(PublicKey);
return rsa.Decrypt(EncryptedDeviceHash, false) == deviceHash;
}
}
But since public key is not for decrypting and since I cannot replicate the same encrypted string I can't do anything with this logic.