Keygens for a product are able to be produced because the author has put the decrypting routine inside the exe so crackers are able to find them and duplicate them. The trick is to not do this.
In software where i have implemented a serial number system i have done this:
1. Create a program to generate 1000 random serial numbers all with the same amount of chars and save these to a text file. Also have this program create a PB include file creating an array holding MD5 hashes of all the numbers.
2. Include the file into your program.
3. In your app, create a nice registration box asking for a serial number.
4. When you program is running and somebody enters a serial into you nice reg box, MD5 hash it and compare it to the hashes stored in your included array.
5. If there's a match, you know it's genuine and you can enable whatever functionality you have.
6. Store the MD5 hash of the serial in a file or in registry so they don't have to enter it again and check for the existance of this hash on start up of your app.
Of course when someone buys your app give them a serial number from the text file that was generated. Many sites allow you to do this automatically when someone buys a piece of software. Shareit for example.
That is the simplest form of app security i could come up with and has actually served me well. This form can still be cracked by a competent cracker but it stops casual copying. If you ever feel like any serials are doing the rounds on any various warez site just run your serial generating program again and recompile your app and it now has 1000 new serials and the old ones won't work with your newly compiled exe.
To be honest i don't sell a lot of software so 1000 serials is a huge limit for me. If you expected to shift more than that you will need a more robust system.
Serial Generator
Code: Select all
;Return a random number in a specified range
Procedure RandomFromRange(Maximum.l, Minimum.l)
ProcedureReturn Maximum - Random(Maximum - Minimum)
EndProcedure
CreateFile(1, "Serial Numbers.txt")
For x = 1 To 1000
For y = 1 To 4
Serial.s + Chr(RandomFromRange(90, 65))
Next y
Serial + "-"
For y = 1 To 4
Serial.s + Chr(RandomFromRange(90, 65))
Next y
Serial + "-"
For y = 1 To 4
Serial.s + Chr(RandomFromRange(90, 65))
Next y
Serial + "-"
For y = 1 To 4
Serial.s + Chr(RandomFromRange(90, 65))
Next y
WriteStringN(1, Serial)
Serial = ""
Next x
CloseFile(1)
Convert to hashes
Code: Select all
x.l = 0
ReadFile(1, "Serial Numbers.txt")
CreateFile(2, "Serial MD5s.pbi")
WriteStringN(2, "Dim ValidCodes.s(999)")
Repeat
String.s = ReadString(1)
WriteStringN(2, "ValidCodes("+Str(x)+") = " + Chr(34) + MD5Fingerprint(@String, Len(String)) + Chr(34))
x+1
Until Loc(1) = Lof(1)
CloseFile(2)
CloseFile(1)