Eradicator Posted August 22, 2008 Share Posted August 22, 2008 Greetings, I wrote a basic CD-key system, and I want to know whether it can be optimized. I don't see anything that could make it any faster, but i'd like a second opinion. It works by downloading a list of encrypted CD-keys and decrypting them while comparing them to what the user has entered. Here is the code. expandcollapse popup$location = "http://fakewebsite.com/cdkeys.txt" $password = "encryptionkey" $key = IniRead(@ScriptDir & "\cd-key.ini", "CD-KEY", "KEY", "") If $key = "" Then $key = InputBox("Hotkeys - CD-Key", "Please enter your CD-Key here to activate your installation.") If $key = "" Then Exit EndIf IniWriteSection(@ScriptDir & "\cd-key.ini","CD-KEY", "KEY=" & $key) EndIf $text = _INetGetSource($location) TrayTip("Verifying", "Checking status of your installation.", 10, 1) $array = StringSplit($text, @CrLf) $i = 1 For $i = 1 To _ArraySize($array) Step 2 If $key <> _StringEncrypt(0, $array[$i], $password, "1") Then If $i = _ArraySize($array) - 1 Then TrayTip("Error", "You have entered an invalid CD-Key or your installation has been disabled by [CE]Eradicator.", 10, 3) MsgBox(16, "Hotkeys - Error", "You have entered an invalid CD-Key or your installation has been disabled by [CE]Eradicator. Please restart the application and enter a valid CD-Key.") If FileExists(@ScriptDir & "\cd-key.ini") Then FileDelete(@ScriptDir & "\cd-key.ini") EndIf Exit EndIf Else $i = _ArraySize($array) TrayTip("Completed", "Your installation has been verified.", 10, 2) ExitLoop EndIf Next And heres that UDF. (I can't remimber who wrote it, i'd appreciate if anyone can point out who made it.) Func _ArraySize( $aArray ) SetError( 0 ) $index = 0 Do $pop = _ArrayPop( $aArray ) $index = $index + 1 Until @error = 1 Return $index - 1 EndFunc Thanks in advance. Regards, Eradicator Link to comment Share on other sites More sharing options...
Richard Robertson Posted August 22, 2008 Share Posted August 22, 2008 For safety's sake, it'd be better to send the key to the server and have the server verify it. That way, someone can't just monitor network traffic and get the entire list of keys. Link to comment Share on other sites More sharing options...
Eradicator Posted August 22, 2008 Author Share Posted August 22, 2008 (edited) For safety's sake, it'd be better to send the key to the server and have the server verify it. That way, someone can't just monitor network traffic and get the entire list of keys.Actually, the reason I didn't do that is because the server is an older web server and I didn't figure AutoIt can write a stable basic small scale data exchange server. (Which would mean running at least three days without needing a restart.)Regards,Eradicator Edited August 22, 2008 by Eradicator Link to comment Share on other sites More sharing options...
Richard Robertson Posted August 22, 2008 Share Posted August 22, 2008 (edited) I was thinking PHP or ASP or any of the other server side languages. Oh and, I'm pretty sure AutoIt will run alright for extended periods of time. I haven't seen anything that would give me reason to think otherwise. One more edit... I noticed your _ArraySize call..? You could just use UBound instead. Edited August 22, 2008 by Richard Robertson Link to comment Share on other sites More sharing options...
Eradicator Posted August 22, 2008 Author Share Posted August 22, 2008 I was thinking PHP or ASP or any of the other server side languages.Oh and, I'm pretty sure AutoIt will run alright for extended periods of time. I haven't seen anything that would give me reason to think otherwise.One more edit... I noticed your _ArraySize call..? You could just use UBound instead.Can you give me an example of how to pass an argument (in this case, the cd-key) to a .PHP or .ASP page?Regards,Eradicator Link to comment Share on other sites More sharing options...
Distrophy Posted August 22, 2008 Share Posted August 22, 2008 Oh and, I'm pretty sure AutoIt will run alright for extended periods of time. I haven't seen anything that would give me reason to think otherwise.I have an autoitscript running on server2k3 for over a month now. Works fine. Link to comment Share on other sites More sharing options...
Richard Robertson Posted August 22, 2008 Share Posted August 22, 2008 Just send it tacked on the end like "http://fakesite.com/check.php?key=0478962" and then in the PHP (I don't know how to use ASP) you call $_GET["key"] and that gives you the value of the parameter (in the example 0478962). Link to comment Share on other sites More sharing options...
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