There is no absolutely reliable method to achieve the desired. If you have a hash file, the user can modify the file and restore the hash, and then your program will assume that the file is not modified. If you try to hide the hash in the registry, the user can easily use the SysInternals tools to determine the location where you save it.
Instead, you can sign a hash-like digital file, with the exception of the secret key. Again, you have a problem that the key must be kept secret, and its storage in the application or somewhere on the computer leaves the possibility for the user to find the key, and then again he can change the file and resign. that this modification is not detected by your program.
Perhaps your application can send a file, or perhaps just a file hash for efficiency, to the web service you are creating. The web service can digitally sign the file or hash and return the signature or store it on the server. Later, when the application reads the file, it can use the open and signal server (you must get it from the server to make sure the file was signed by the server) to check that the file has not been modified. Or you can resend the file or hash to the server if the server has saved the signature and it can verify the file and return the result to the application. Again, this is not complete proof. There would be ways for a user to spoof a web service, even if you are using SSL, there are ways to get around this. The user can completely hack your application and delete the verification code.
Judging by your other questions, this is part of the software activation system component. Just take a look at Adobe and Microsoft, and their unsuccessful attempts to create such a system. If you think you can do better, good luck. There are better ways to ensure that your software is used legally without activation systems that only frustrate your regular users.
source share