Jump to content

Serial Key Generater


James
 Share

Recommended Posts

Hey,

I know this is really simple etc, but if you want to sell your program, and want to have a special key with their name on etc, then this is the way to do it.

The name is Encrypted in this case using the key: "HGA45$90" to encypt the name.

Here is the code,

#cs
    Name: Program Registration
    Author: James Brooks
#ce

#include <GuiConstants.au3>
#include <String.au3>

Global $AccsKey = "HGA45$90"

$GUI = GUICreate("Program Registration", 397, 249, -1, -1)
$RegistrationGroup = GUICtrlCreateGroup("&Registration", 8, 8, 377, 113)
$NameLabel = GUICtrlCreateLabel("Name:", 16, 32, 35, 17)
$SerialLabel = GUICtrlCreateLabel("Serial:", 16, 96, 33, 17)
$RegName = GUICtrlCreateInput("", 56, 24, 313, 21)
$SerialKeyReg = GUICtrlCreateInput("", 56, 88, 313, 21)
$GenerateKey = GUICtrlCreateButton("&Generate Serial", 144, 48, 81, 33, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$InputForm = GUICtrlCreateGroup("&Register Program", 8, 128, 377, 113)
$NameInputLabel = GUICtrlCreateLabel("Name:", 16, 152, 35, 17)
$RegNameInput = GUICtrlCreateInput("", 56, 144, 313, 21)
$SerialLab = GUICtrlCreateLabel("Serial:", 16, 176, 33, 17)
$Serial = GUICtrlCreateInput("", 56, 168, 313, 21)
$Register = GUICtrlCreateButton("&Register", 296, 200, 73, 33, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GenerateKey
            Generate($RegName)
        Case $Register
            Register($RegNameInput)
    EndSwitch
WEnd

Func Generate($Name)
    $ReadName = GuiCtrlRead($Name)
    $Encrypt = _StringEncrypt(1, $ReadName, $AccsKey)
    GuiCtrlSetData($SerialKeyReg, $Encrypt)
EndFunc

Func Register($io_Name)
    $RegisterName = GuiCtrlRead($io_Name)
    $SerialRead = GuiCtrlRead($Serial)
    $Decrypt = _StringEncrypt(0, $SerialRead, $AccsKey)
    If $Registername = $Decrypt Then 
        MsgBox(4096, "Continue", "Congrats")
    Else
        MsgBox(16, "Error", "Incorrect serial key!")
    EndIf
EndFunc

You obviously would need to make the key longer and store in the registry somewhere, but this just shows you a basic way of making the keys.

I know it not greatly useful, but I used it when I sold someone a program they wanted.

Check out the new real-time encryption, with the abillity to define your own encryption key here!

Thanks,

James

Edit: Removed useless include.

Edit: Changed topic title.

Edited by NeoTroniX
Link to comment
Share on other sites

Update

Real-time encryption and define your own encyption key:

#include <GUIConstants.au3>
#include <String.au3>

#Compiler_Icon=infoicon.ico

Opt("TrayIconHide", 1)

Local $oldStr

$GUI = GUICreate("Serial Key Generator", 303, 146, -1, -1)
GUISetBkColor(0x339DD2)
$NameLabel = GUICtrlCreateLabel("Name:", 8, 12, 42, 17)
GUICtrlSetColor(-1, 0xFFFFFF)
$Name = GUICtrlCreateInput("", 48, 8, 249, 21)
$SerialLabel = GUICtrlCreateLabel("Serial:", 8, 44, 33, 17)
GUICtrlSetColor(-1, 0xFFFFFF)
$Serial = GUICtrlCreateInput("", 48, 40, 249, 21)
$KeyLabel = GuiCtrlCreateLabel("Key:", 8, 76, -1, -1)
GUICtrlSetColor(-1, 0xFFFFFF)
$Key = GuiCtrlCreateInput("a1b2c3", 48, 72, 249, 21)
$Copy = GuiCtrlCreateButton("&Copy Serial", 130, 100, 81, 33, 0)
$Exit = GUICtrlCreateButton("&Exit", 216, 100, 81, 33, 0)

GUISetState(@SW_SHOW)

While 1
    If @OSVersion = "WIN_95" or "WIN_98" or "WIN_ME" Then
        ProcessSetPriority($GUI, 2)
    ElseIf @OSVersion = "WIN_NT4" or "WIN_2000" or "WIN_XP" or "WIN_2003" or "WIN_VISTA" Then
        ProcessSetPriority($GUI, 4)
    EndIf
    $Str = GUICtrlRead($Name)
    If $Str <> $oldStr Then
        $EncryptedStr = _StringEncrypt(1, $Str, GuiCtrlRead($Key))
        If $EncryptedStr <> "" Then
            GUICtrlSetData($Serial, $EncryptedStr)
        Else
            GUICtrlSetData($Serial, "")
        EndIf
        $oldStr = $Str
    EndIf
    If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
    If GUIGetMsg() = $Exit Then Exit
    If GUIGetMsg() = $Copy Then ClipPut(GuiCtrlRead($Serial))
WEnd

Func OnAutoItExit()
    MsgBox(4096, "Goodbye", "Thankyou for using the Password generator, created by James Brooks. 2007!")
EndFunc

http://www.autoitscript.com/fileman/users/public/Secure_ICT/RealEncryption.PNG

Please leave feedback!

Edited by NeoTroniX
Link to comment
Share on other sites

  • 2 weeks later...

Why not use something like..

$Randoms = _RandomText(4) & "-" & _RandomText(4) & "-" & _RandomText(4)
Msgbox(0,"",$Randoms)

Func _RandomText($N)
    If $N < 1 Then Return -1
    Local $COUNTER, $ALPHA, $RESULT
    For $COUNTER = 1 To $N
        If Random() < 0.5 Then
            $ALPHA = Chr(Random(Asc("A"), Asc("Z") + 1))
        Else
            $ALPHA = Chr(Random(Asc("a"), Asc("z") + 1))
        EndIf
        $RESULT = $RESULT & $ALPHA
    Next
    Return $RESULT
EndFunc  ;==>_RandomText

I forget who wrote this function, it was found somewhere on the forums.

Kurt

Awaiting Diablo III..

Link to comment
Share on other sites

Why not use something like..

$Randoms = _RandomText(4) & "-" & _RandomText(4) & "-" & _RandomText(4)
Msgbox(0,"",$Randoms)

Func _RandomText($N)
    If $N < 1 Then Return -1
    Local $COUNTER, $ALPHA, $RESULT
    For $COUNTER = 1 To $N
        If Random() < 0.5 Then
            $ALPHA = Chr(Random(Asc("A"), Asc("Z") + 1))
        Else
            $ALPHA = Chr(Random(Asc("a"), Asc("z") + 1))
        EndIf
        $RESULT = $RESULT & $ALPHA
    Next
    Return $RESULT
EndFunc  ;==>_RandomText

I forget who wrote this function, it was found somewhere on the forums.

Kurt

How do you check if the code is true?

With random serial you must give it at user, but how does the program verify the validate?

A lan chat (Multilanguage)LanMuleFile transferTank gameTank 2 an online game[center]L'esperienza è il nome che tutti danno ai propri errori.Experience is the name everyone gives to their mistakes.Oscar Wilde[/center]
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...