erebus 1 Posted November 11, 2004 Hello all, I have written two scripts where the first writes some game CD keys to an ini file as values and the second one reads them. The problem is that while the .ini file is located in an SMB Windows share folder, can be manually read by everyone in the LAN since the CD key values are human readable. Can someone throw me a bone of how to achieve a (basic) encryption/decryption for these values to avoid this issue? Hint1: CD key format example: a. HJ7MVH-EKZ9-BVM6Z6-FYDX-CMGTBG (Warcraft III) b. RV9VEM-7T67-6H7C8E-K7WD-JBHCE2 (Frozen Throne) Hint2: The idea is to use the encryption, not the hidden windows' shares. Thanks in advance for your time.. Share this post Link to post Share on other sites
ezzetabi 3 Posted November 11, 2004 What about a Rot-13? It is easy to implement, but weak. It is enough for you? Otherwiseuse the idea.com scripts. Share this post Link to post Share on other sites
CyberSlug 6 Posted November 11, 2004 You could instead/additionaly re-order the sections of the key: ; PLAIN TEXT $cdkey = "EXMPL-CDKEY-GOES0-HERE0-12345" $key = StringSplit($cdkey, "-") ; ENCRYPTING $encrypted = $key[2] & $key[5] & $key[1] & $key[4] & $key[3] ; this stores CDKEY-12345-EXMPL-HERE0-GOES0 ;..... ; DECRYPTING $d = StringSplit($encrypted, "-") $decrypted = $d[3] & $d[1] & $d[5] & $d[4] & $d[2] Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Share this post Link to post Share on other sites
erebus 1 Posted November 11, 2004 (edited) @CyberSlug: This is a good idea, however someone can easily image the trick if manages to see the ini file. I 've also thought of reversing some of the splitted strings, but it makes no difference; it's too weak.@ezzetabi: Thanks for the tip, I was totally unaware of the ROT13 method. However as I checked a bit, it's a game for someone to break it (check the online tool @ http://www.rot13.com for instance).Searching the AutoIT forums I found your two great ROT13 functions in an old post. If we take the CyberSlug's function as an example (which code seems more compact) could we alter it in an easy way to customize the ROT13 encryption?Correct me if I am wrong but I think that this kind of encryption is based on numbers. By using total different numbers in the function (or even better a passphrase) don't we achieve a new encryption method (assuming that the new encryption source code is unavailable)?Thank you. Edited November 11, 2004 by erebus Share this post Link to post Share on other sites
Mr.Wizard 0 Posted November 11, 2004 Try this: Opt("MustDeclareVars", 1) dim $notencrypted = "HJ7MVH-EKZ9-BVM6Z6-FYDX-CMGTBG (Warcraft III)" dim $encrypted = encdec($notencrypted) dim $decrypted = encdec($encrypted) MsgBox(0, "xor encryption test", "before encryption: " & $notencrypted & @crlf & @crlf & "after encryption: " & $encrypted & @crlf & @crlf & "after decryption: " & $decrypted) Func EncDec($original) dim $modified dim $key = "I am the magic key" dim $pos_original, $pos_key For $pos_original = 1 To StringLen($original) If $pos_key = StringLen($key) Then $pos_key = 1 Else $pos_key = $pos_key + 1 EndIf $modified = $modified & Chr(BitXOR(Asc(StringMid($original, $pos_original, 1)), Asc(StringMid($key, $pos_key, 1)), 255)) Next Return $modified EndFunc I have a catapult. Give me all the money or I will fling an enormous rock at your head. Share this post Link to post Share on other sites
ezzetabi 3 Posted November 11, 2004 Check here.http://www.autoitscript.com/forum/index.php?showtopic=2611Using idea.com and this sample code you should not have problems. Do the following.Encrypt the file,Make a script the decrypt, read the .ini encrypt again.Enjoy. Share this post Link to post Share on other sites
erebus 1 Posted November 11, 2004 @ezzetabi: I really like the way you code pal. This is another excellent idea, thank you very much! @Mr.Wizard: Great functions too, thanks a lot for your time. Amazing results! Share this post Link to post Share on other sites
JSThePatriot 18 Posted November 11, 2004 Hey... I just created a program that will use AxCrypt (look on sourceforge for it) that will automatically encrypt files. I think AxCrypt would be what you are looking for as you can have AutoIt automate it. It has command line parameters. Once I get home I will give you the web address and such if you are interested. I will be posting my script in the scripts and scraps section once it is finished. JS AutoIt LinksFile-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.ComputerGetInfo UDF's Updated! 11-23-2006External LinksVortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Share this post Link to post Share on other sites
erebus 1 Posted November 13, 2004 Thank you very much, I 've already used Mr.Wizard's solution so as to use something quick and handy. I would like to see your adaptation with AxCrypt, it should be very interesting! Share this post Link to post Share on other sites