Best way to check for trial expiration

P

peter

Does anyone have solid code for setting up a 30 day experiation timer
on your software.

-Peter
 
B

Bob Powell [MVP]

I can't give away code because it's for a commercial client however I
recently did a system that uses a LicenseProvider derived object to enable a
class to run within a 30 day limit.

I used a specially coded string such as:

"This is my uncrackable code string for Friday December 17 2004"

In fact the string has a bunch of stuff in it that is encrypted in the
application and used for licensing my code but you get the picture. I use
this string to create a hash-key using MD5 encryption which I store in a
config file.. I also store the install date in plain text in the config file
local to the app.

In the LicenseProvider I reconstruct my string from details I know, add the
stored date to the end and then create an MD5 hash with it. If it's the same
as the stored hash I know that the licensing rules I chose were valid *and*
that the install date is also valid. If the user attempts to extend the demo
period by altering the date the hash key is different and the licensing
fails anyway.

If my licensing succeeds, ie if I have the right install date, I can then
decide whether this code times out after 30 days and refuse to return a
valid license if it does.

I think it's very important that you obfuscate your object with a good
obfuscator that encrypts strings. I use Xenocode becase it will also crash
IL disassemblers. This hides the internal information I use to decide my
licensing policy.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
N

Nak

Hi Peter,
Does anyone have solid code for setting up a 30 day experiation timer
on your software.

Before committing yourself to making trialware you might want to
consider making a restricted demo instead. This can be achieved using
pre-compile directives, i.e.

#IF (Not DEMOVERSION)
Do full version stuff, this code will not be in the
demo version, it does not get compiled
#ELSE
Display error message and information on upgrading,
this code will not be in the full version, it does not get
compiled.
#END IF

The reason I say this is because you would then end up with 2 versions
of your application, a full version and a demo version, the demo version
would be impossible to change into the full version as the full version code
wouldn't even be compiled into the executable.

If you were to do as Bob Powell suggests you would have to hard code the
expiration date into the application, thus the timer would not start when
the application is first installed. This *may* be an issue to you depending
on how your distributing your application.

If you choose to make a demo and full version you can then implement a
license provider to protect your full version, if no license is available
refuse to run. This makes the licensing fiasco much easier to deal with
than attempting to hide installation dates around the users system which
will always be found.

My personal opinion is that if .NET code is so easily decompiled, you
may as well make that the *only* way a hacker is going to get it working,
make them resort to diving around in thousands of lines of code. I've
implemented licensing in this way and believe it to be most effective, I'm
not distributing "nagware" to the public, which I find highly irritating.

Anyway, just my 2 pence worth.

Nick.
 
Joined
Nov 21, 2009
Messages
79
Reaction score
0
Store the date in the registry during first use. Then each time your app runs, calculate the number of days passed and stop running after 30 days.

Also look at CryptoLicensing, which does this and more.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top