DaLiMan Posted February 9, 2005 Posted February 9, 2005 Hi, Does someone have a good idea on how to accomplish a sort of registration key for a program. I would like users to ask for a key [which must be random for else it would be no use] so I can limit / keep track of the installed copies. Doesn't have to be hard to crack though. Please, anything is welcome.
Marc Posted February 9, 2005 Posted February 9, 2005 Just a simple key, created randomized? Easy... $keycode = "" For $i = 1 To 20 ;Random letter If Random() < 0.8 Then; 80% Chars ;Capitals $letter = Chr(Random(Asc("A"), Asc("Z"), 1)) Else ; 20% Decimals $letter = Chr(Random(Asc("0"), Asc("9"), 1)) EndIf $keycode = $keycode & $letter If (Mod($i,4)=0) And ($i<20) Then $keycode = $keycode & "-" Next MsgBox(0, "Keycode", $keycode) (Based on the Random() example in the helpfile.) Hope this helps, Marc Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL)
DaLiMan Posted February 9, 2005 Author Posted February 9, 2005 At least it gives me insight on how to create a random key, but how can I check for a "registered" key this way? I want them to give a key, depending on the user. Is this possible? For example: User1 - Key: A-A-B-B User2 - Key: B-B-A-A User3 - Key: B-A-B-A if User1 gives in the key of User2 the program won't work etc... Maybe creating a key on some data (name or something) from the user. Is this possible?
polenius Posted February 9, 2005 Posted February 9, 2005 At least it gives me insight on how to create a random key,but how can I check for a "registered" key this way?I want them to give a key, depending on the user.Is this possible?For example:User1 - Key: A-A-B-BUser2 - Key: B-B-A-AUser3 - Key: B-A-B-Aif User1 gives in the key of User2 the program won't work etc...Maybe creating a key on some data (name or something) from the user.Is this possible?<{POST_SNAPBACK}>What about simple hash? You can sum all ascii codes values of each character in macro @UserName. Now you can do something like this : $HashValue = Mod($sum,128)The last step is generating random key with hash equall to $HashValue.
Marc Posted February 9, 2005 Posted February 9, 2005 You have several options here... one solution could be to just check whether a specific key is valid, for example prevent all keys to have the number 7 in it. If a user enters a key containing a "7" it's not valid. Make a checksum check on each part of the serial, lets say add all Values of each part then check if the first part can be divided by 2, the 2nd block has to be dividable by 4, ... Or you're going the way you're suggesting, let the user enter his name and the according key and use a cheap XOR encoding like this one... $secret="AutoIt" $realcode="" $name = InputBox("Enter user name","Please enter your name","blah") $code = InputBox("Enter serial","Please enter your serial") For $i = 1 to StringLen($secret) $temp = BitXOR (Asc(StringMid($secret,$i,1)), Asc(StringMid($name,$i,1))) $realcode = $realcode & hex($temp,2) Next ClipPut($realcode) if $code = $realcode Then MsgBox(0,"Ok", "Successfully registered") Else MsgBox(0,"Wrong Serial", "Real Serial: " & $realcode) EndIf Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL)
DaLiMan Posted February 9, 2005 Author Posted February 9, 2005 I was going about the wrong way for this one. I now have a little script (not very neat but efficient enough) that looks like this: #include <string.au3> Dim $keycode = "" Dim $Naam = @UserName Dim $PlaatsReg = @ComputerName Dim $User = $Naam&"-"&$PlaatsReg MsgBox(0, "Naam en Computer", $user) $mid1 = StringLeft(_StringToHex(StringMid($user, 1,4)),4) $mid2 = StringLeft(_StringToHex(StringMid($user, 5,4)),4) $mid3 = StringLeft(_StringToHex(StringMid($user, 9,4)),4) $mid4 = StringLeft(_StringToHex(StringMid($user, 13,4)),4) MsgBox(0, "Keycode", $mid1&"-"&$mid2&"-"&$mid3&"-"&$mid4) Exit Most won't even try to hack it, for the registration number will be given to them and I can keep up with the copies. Thanx Marc, youre code looks nice too. Have tried it out and is very usefull for my app. Maybe I will make a mix of both....
layer Posted February 9, 2005 Posted February 9, 2005 idk if this is what yyou want... #include <GUIConstants.au3> GUICreate ("Random Generator", 200, 100) $char= GUICtrlCreateInput ("# of characters outputted", 10, 20, 140) $make= GUICtrlCreatebutton ("Make", 10, 60) $pw= GUICtrlCreateEdit ("", 70, 63.5, 125, 20, $ES_READONLY) $clear= GUICtrlCreateButton ("Clear", 155, 15) GUICtrlCreateLabel ("Output:", 135, 40) GUICtrlSetState ($char, $GUI_FOCUS) GUISetState () While 1 $get= GUIGetMsg () If $get= $make then Generate () If $get= $clear then Clear () If $get= -3 then Exit WEnd Func Generate () $read= GUICtrlRead ($char) If NOT StringIsDigit($read) Then Return $read= Number($read) GuictrlSetData ($pw, "") GUICtrlSetLimit ($pw, $read) For $i = 1 To $read $pass= Chr(Random(Asc("a"), Asc("z"), 1)) GuictrlSetData ($pw, $pass, 1) GUICtrlSetData ($pw, Random (0, 9, 1), 1) Next EndFunc Func Clear () GUICtrlDelete ($char) $char= GUICtrlCreateInput ("# of characters outputted", 10, 20, 140) GUICtrlDelete ($pw) $pw= GUICtrlCreateEdit ("", 70, 63.5, 125, 20, $ES_READONLY) GUICtrlSetState ($char, $GUI_FOCUS) EndFunc FootbaG
MSLx Fanboy Posted February 9, 2005 Posted February 9, 2005 I'm fond of MD5 hashing (php-geek...), I'd say md5 sum of username or the person's name, perform a few functions on the md5 sum so that its not recognizable, and then give them the final output. I have the MD5 sum tool at home for strings, I'll upload that later... Note to self: Modify au3/dll to allow for files as well... Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate())
DaLiMan Posted February 10, 2005 Author Posted February 10, 2005 I'm fond of MD5 hashing (php-geek...), I'd say md5 sum of username or the person's name, perform a few functions on the md5 sum so that its not recognizable, and then give them the final output. I have the MD5 sum tool at home for strings, I'll upload that later...Note to self: Modify au3/dll to allow for files as well...<{POST_SNAPBACK}>I don't understand any of it..... (don't now any other language than Auto-It and HTML [duh]) But I'm very interested in youre script.Can you paste a copy of it?
polenius Posted February 10, 2005 Posted February 10, 2005 I don't understand any of it..... (don't now any other language than Auto-It and HTML [duh]) But I'm very interested in youre script.Can you paste a copy of it?<{POST_SNAPBACK}>Little help: MD5 is standardized security hash function. You can express it like common function MD5($something). The result will be 128 bit hash string which looks "very randomly".
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now