ClioSport.net

Register a free account today to become a member!
Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

License Key Generator



  Bumder With A Buffer
Hello guys and girls!

Im after a bit of some assistance in making or getting something that can generate A license key for an application we use. Basically a random number generator but in the form of a licence key. Im not clued up on this stuff at all so have no idea what to look for though i know what i want it to do!

Could this be done in excel using macro's or would i have to do it in visual basic/c+ or whatever?

Any pointers in the right direction would be great!

Cheers
Richy
 
Sorry that was a bit brief. It is easy to genrate a random serious of alpanumerics in any language.

i.e. using reglar expresions you could say genetare me a string wich is in the form

A34F-E34G-D789-ABEG

The hard part is the bit that checks if that is a valid licence key. You need to run a checksum against the licence key to see if it is valid or not. If you don't use a checksum you would need to record all valid licence keys for your product.

So you use a formula to generate the licence key and a formula to validate it.
 

sn00p

ClioSport Club Member
  A blue one.
What information do you want the license key to hold?

look up md5 hashes and RSA encryption.

Basic idea is to create a hash of the license information, then use RSA or other public key encryption to sign it.
 
  Bumder With A Buffer
basically 18 numbers split into 3 so 6 lots of 3 numbers. At the mo they have to add up to 4095 and are ranged between 100 and 999. But it can also be any number devisable by 65 i believe. Think the software does a checksum.... it must if it has to be devisable by 65 or add upto 4095?

Am i correct?!! Basically this should be our electronics guys job but hes useless!!
 
sn00p said:
What information do you want the license key to hold?

look up md5 hashes and RSA encryption.

Basic idea is to create a hash of the license information, then use RSA or other public key encryption to sign it.

Would this method not still require a database of all the licenece keys you use? So when a licence key is entered the hash's can be compared?
 
So do you want to caculate all the possible licence key combos rather than writing a licnce key into your software?
 
  Bumder With A Buffer
yeah sorry the software already has that writing into it (every possible combination) what i wanna do is have a bit of software or whatever that can generate this number coz at the mo have to do it in our head which can take time if people cant add up properly!
 

sn00p

ClioSport Club Member
  A blue one.
disco said:
Would this method not still require a database of all the licenece keys you use? So when a licence key is entered the hash's can be compared?

Not in the application, the signing of the hash with the public key encryption gives a straight yes/no answer to whether the "license key" is valid.

When they type in the key, a hash is generated and compared against the hash in the "license key".

You'll need to store the "serial number hash" in a database back home so you can marry then back up, remember that a hash is a one way function. And you need to avoid hashes that have collisions.

Or you could avoid hashes and just sign the raw "serial number" etc.
 
  Bumder With A Buffer
As far as im aware the software inly looks for a specific number, devisable by 65 or adds up to 4095. So at the minute i can use the same license key on ANY install of this software. Ideally want this to change so that it can only be used once but not priority at the minute.
 
another quick question do the groups of 3 's add up to 4095 or each individual number

i.e. 456 + 187 ect or 4+5+6+7
 
Dim licenceKey
Dim licenceKeyCheckSum
Dim intHighestNumber
Dim licenceKeyPart1
Dim licenceKeyPart2
Dim licenceKeyPart3
Dim licenceKeyPart4
Dim licenceKeyPart5
Dim licenceKeyPart6

intHighestNumber = 999
licenceKeyPart1 = 0
licenceKeyPart2 = 0
licenceKeyPart3 = 0
licenceKeyPart4 = 0
licenceKeyPart5 = 0
licenceKeyPart6 = 0

licenceKey = ""

RandomNumber(intHighestNumber)

Do While (licenceKeyCheckSum <> 4095)

licenceKeyPart1 = RandomNumber(intHighestNumber)
licenceKeyPart2 = RandomNumber(intHighestNumber)
licenceKeyPart3 = RandomNumber(intHighestNumber)
licenceKeyPart4 = RandomNumber(intHighestNumber)
licenceKeyPart5 = RandomNumber(intHighestNumber)
licenceKeyPart6 = RandomNumber(intHighestNumber)

licenceKeyCheckSum = licenceKeyPart1+licenceKeyPart2+licenceKeyPart3+licenceKeyPart4+licenceKeyPart5+licenceKeyPart6


Loop

licenceKey = licenceKeyPart1&"-"&licenceKeyPart2&"-"&licenceKeyPart3&"-"&licenceKeyPart4&"-"&licenceKeyPart5&"-"&licenceKeyPart6

Function RandomNumber(intHighestNumber)
Do While RandomNumber < 100
Randomize
RandomNumber = Int(Rnd * intHighestNumber) + 1
Loop
End Function


WScript.Echo licenceKey

Set licenceKey = Nothing
Set licenceKeyCheckSum = Nothing
Set intHighestNumber = Nothing
Set licenceKeyPart1 = Nothing
Set licenceKeyPart2 = Nothing
Set licenceKeyPart3 = Nothing
Set licenceKeyPart4 = Nothing
Set licenceKeyPart5 = Nothing
Set licenceKeyPart6 = Nothing
 
Stick the above into a text file rename genLicenceKey.vbs and double click. It is crude and I haven't done the bit that works out if it is divisable by 65 but it is a start :)
 
There is probably a much more efficient way to do this using a formula to gen the number the above is crude. But I can't be arsed to do the maths to work out a formula
 
Last edited:
  Bumder With A Buffer
Hell thats awesome!! Christ weren't expecting that!! Cheers for your help buddy!

Out of interest what did u use to do that? i.e visual basic or something?? Im trying to learn all this programming stuff at the mo!
 
  Bumder With A Buffer
LOL

Ok when i open it i get a windows script host error

Script: C:\Documents and Settings\rgreen\My Documents\genLicenceKey.vbs
Line: 32
Char: 73
Error: Expected end of statement
Code: 800A0401
Source: Microsoft VBScript compilation error
 

sn00p

ClioSport Club Member
  A blue one.
Do yourself a favour (and presumably the company you work for) and ditch that method of serial number generation! Poor!

It'll take you a long time to generate all possible serial numbers, that a large maximum value, 999-999-999-999-999-999 - but if you really want to do it, then something like this...

Code:
int main(void)
{
  unsigned long long i,j,k; // 64 bit long
  char temp[40], tuples[6][4];

  for (i=0;i<999999999999999999;i++)
  {
    sprintf(temp, "%.18ld", i);

    for (j=0,k=0;j<6;j++)
    {
      tuples[j][3] = '\0';
      strncpy(&tuples[j][0], &temp[j*3], 3);
      k += atoi(&tuples[j][0]);
    }

    if ( (k==4095) || ((i % 65)==0))
    {
      for (j=0;j<6;j++)
      {
        printf("%s", &tuples[j][0]);

        if (j!=5)
          printf("-");
      }
      printf("\r\n");
    }
  }
}
Haven't tested that, but that'd brute force every key to maximum and output valid ones to the screen. Might take a while though! lol.

Edit: And you'd need a compiler that supports 64 bit integers. (long long)
 
Last edited:
  Bumder With A Buffer
wicked!! ok im getting a microsoft script error when i try to open it... think i did something wrong!
 

sn00p

ClioSport Club Member
  A blue one.
I find it slightly amusing that whatever software you're writing, 2 of us have written keygens for it! lol.
 
  Bumder With A Buffer
LOL i dont write the software! Wish i could do it though! Just wanting to simplify the process of generating the number! Ideally not my job but no1 here can do this kinda thing!
 
  Bumder With A Buffer
Brainier people than me thats for sure.... or just well educated!!

The code you gave me.... put into a text file and saved it as you said, but i get th t script error when i try to open it. What have i done wrong!
 
Stange it is running fine at my end!

I would just ditch it and start a new file then do the cut and paste again or are you trying to run snoops code? cause it isn't VB Script so won't run in the same way.
 
Code:
Dim licenceKey
Dim licenceKeyCheckSum
Dim intHighestNumber
Dim licenceKeyPart1
Dim licenceKeyPart2
Dim licenceKeyPart3
Dim licenceKeyPart4
Dim licenceKeyPart5
Dim licenceKeyPart6

intHighestNumber = 999
licenceKeyPart1 = 0
licenceKeyPart2 = 0
licenceKeyPart3 = 0
licenceKeyPart4 = 0
licenceKeyPart5 = 0
licenceKeyPart6 = 0

licenceKeyCheckSum = 1

licenceKey = ""

RandomNumber(intHighestNumber)

Do While (licenceKeyCheckSum <> 4095 And (licenceKeyCheckSum Mod 65 <> 0))

licenceKeyPart1 = RandomNumber(intHighestNumber)
licenceKeyPart2 = RandomNumber(intHighestNumber)
licenceKeyPart3 = RandomNumber(intHighestNumber)
licenceKeyPart4 = RandomNumber(intHighestNumber)
licenceKeyPart5 = RandomNumber(intHighestNumber)
licenceKeyPart6 = RandomNumber(intHighestNumber)

licenceKeyCheckSum = licenceKeyPart1+licenceKeyPart2+licenceKeyPart3+licenceKeyPart4+licenceKeyPart5+licenceKeyPart6


Loop 

licenceKey = licenceKeyPart1&"-"&licenceKeyPart2&"-"&licenceKeyPart3&"-"&licenceKeyPart4&"-"&licenceKeyPart5&"-"&licenceKeyPart6

Function RandomNumber(intHighestNumber)
Do While RandomNumber < 100
Randomize 
RandomNumber = Int(Rnd * intHighestNumber) + 1
Loop
End Function


WScript.Echo licenceKey

Set licenceKey = Nothing
Set licenceKeyCheckSum = Nothing
Set intHighestNumber = Nothing
Set licenceKeyPart1 = Nothing
Set licenceKeyPart2 = Nothing
Set licenceKeyPart3 = Nothing
Set licenceKeyPart4 = Nothing
Set licenceKeyPart5 = Nothing
Set licenceKeyPart6 = Nothing
 
Last edited:

sn00p

ClioSport Club Member
  A blue one.
disco said:
Try again think something went wrong during pasting.

stick it in code tags mate.

My code you'll need a 'C' compiler, the free microsoft one will do.
 
ah ha go to line 34 and get rid of the space in

li cenceKeyPart4

so it reads

licenceKeyPart4

cutting and pasting from the form breaks it for some reason!
 
  Bumder With A Buffer
Yeah its the one you did DISCO. Did it again named it and saved it as vbs file but still get that error. Might be my computer maybe! Il have a play
 
richy22 said:
Yeah its the one you did DISCO. Did it again named it and saved it as vbs file but still get that error. Might be my computer maybe! Il have a play

Not your computer was just cutting and pasting to and from the forum was corrupting the code. Copy it now. Hope it works!

D
 

sn00p

ClioSport Club Member
  A blue one.
got bored. compiled the code and it works.

you are aware that 000-000-000-000-000-000 is a valid serial number?! lol.
 


Top