Friday, July 31, 2009

Visual Basic. Dynamically creating a key, (at runtime) for a program for distribution? How can I do this?

What I am trying to do is figure out how to dynamically create a key at runtime in a program so that I don't have all sorts of programs running around out there that use the same registration key. I am starting to get familiar with Visual Basic.NET and have written a simple program in it and want to learn how I would be able to distribute it and somehow spit out some keycode that is specific to that program. Does anyone know where to start on something like this? I have read some about needing to write to the registry and such and I think I can understand that, I however am not sure how to have the program spit out a keycode according to it's algorithm and spit the key out to me so that when I run it it asks for the key and when I use it it works. I then am sure that I would have to figure out how to tell the registry that it is cool, they have the key.





Any leads? There are several parts to this so even if you have some idea on just one, I would like to hear it.





Thanks...

Visual Basic. Dynamically creating a key, (at runtime) for a program for distribution? How can I do this?
I understand what you are tryin gto do here. Although it is a nice idea there are several small problems:





1) There is a relatively high probability that the key that is created on the users computer could match another users key. How would the algorythm then handle this??





2) Someone could easily disect your algorythm and create unlimited numbers of keys for distribution, WHICH WILL HAPPEN.





Here is an easy reliable solution.





create a guid (globally unique identifier). Guid's are used in the registry to identify applications, dll's etc...





Read a little about them in the IDE index for help





here is the code beind it.





Public Class Form1


Inherits System.Windows.Forms.Form





Private x As New Guid()





Private sub createguid()





console.writeline(x.NewGuid)


End sub





End class








I would also recommend that you create the Guid when the application is downloaded and have it compiled into the code as a resource file before the user downloads it.





This will allow you to check if the Guid has been created before (about a 1 in several trillion chance) and will allow you to create another on if it has already been used.





Read a little more about them. I am certain your idea will become more clear as you read.





Best of luck
Reply:1. have an algorithm to generate keys based on a few choices.


like key = a*100 + a/2 where a = (1..100) (this is too simple)


2. when installing, have the program save, 'a' to disk or registry.


3. when running, have the user type in the key, and compare it with the key retrieved from 'a'.





( if u want more restrictions, u can have a algorithm to generate from say, user's name, then have the user register at some, site, which automatically generates the key, and mails the user. )


No comments:

Post a Comment