You can save the first and last execution date in a file, as well as save the checksum in it. As @Timbo said, any decent hacker will get around this (as with any other method).
Similarly, you can store something like this in a file anywhere (possibly in a register)
20090801:20090815:20090901 ca5579e3bacb7557b6ed22b5f553f9d5
:
20090801 - the start date 20090815 - the last execution date 20090901 - the final date ca5579e3bacb7557b6ed22b5f553f9d5 - the salted MD5 checksum
this way you can check the correctness of the checksum using such an algorithm
bool CheckExpiry() { string SecretSalt = "Y*## d3F!@g ^hk"; string InitialDate = FetchInitialDate(); string LastExecutionDate = FetchLastExecutionDate(); string FinalDate = FetchFinalDate(); int Checksum = FetchChecksum(); string FinalString = InitialDate + ":" + SecretSalt + ":" + LastExecutionDate + ":" + FinalDate; int InternalCheckSum = md5sum( FinalString ); return InternalCheckSum == CheckSum; }
Of course, you can use SHA-1 or any other digest algorithm that you like best. Just make sure you use SecretSalt , which is not easily guessed.
And you can check LastExecutionDate for the current date to check if the date has been changed in the opposite direction.
source share