Skitty Posted January 28, 2011 Share Posted January 28, 2011 (edited) What the script does is reads working script (can be any script that currently works) and encrypts the file line by line individually and then stores the data to a text file and then decrypts it back into an au3 file and launches it with "AutoIt3.exe" which all files should be at the script directory. This isn't very important but I was just messing around with encryption and discovered that nearly everything (but images and executables I think) encrypted with Autoit won't work correctly afterwards. expandcollapse popup#include<string.au3> #include <file.au3> _FileCreate(@ScriptDir & "\Unencrypted.au3") $SCript = "\Code.au3" $handle_read = FileOpen(@ScriptDir&$SCript,0) If $handle_read = -1 Then MsgBox(0, @ScriptName, 'failed to open handle to read the file') Exit 1 EndIf $file_to_write = @ScriptDir & "\Ecryptedcode.txt" $handle_write = FileOpen($file_to_write, 2) If $handle_write = -1 Then FileClose($handle_read) MsgBox(0, @ScriptName, 'failed to open handle to read the file') Exit 2 EndIf While 1 $line_read = FileReadLine($handle_read) If @error Then ExitLoop $1 = _StringEncrypt(1,$line_read,"10",1) FileWriteLine($handle_write, $1) WEnd FileClose($handle_read) FileClose($handle_write) ;///////////////////////////////////////////////////////////////////////////// ;///////////////////////////////////NEXT////////////////////////////////////// ;///////////////////////////////////////////////////////////////////////////// $hndle2read = FileOpen(@ScriptDir & "\Ecryptedcode.txt",0) If $hndle2read = -1 Then MsgBox(0, @ScriptName, 'failed to open handle to read the file') Exit 1 EndIf $fil2write2 = @ScriptDir & "\Unencrypted.au3" $Htowrite = FileOpen($fil2write2, 2) If $Htowrite = -1 Then FileClose($hndle2read) MsgBox(0, @ScriptName, 'failed to open handle to read the file') Exit 2 EndIf While 1 $line2read = FileReadLine($hndle2read) If @error Then ExitLoop $2 = _StringEncrypt(0,$line2read,"10",1) FileWriteLine($Htowrite, $2) WEnd FileClose($hndle2read) FileClose($Htowrite) Run(@ScriptDir & "\AutoIt3.exe" & " " & @ScriptDir & "\Unencrypted.au3") Edited January 28, 2011 by xJSLRx Link to comment Share on other sites More sharing options...
willichan Posted January 28, 2011 Share Posted January 28, 2011 When you try to encrypt an empty string, _StringEncrypt() is returning a 1 in @error. You need to skip encryption/decryption for blank lines if you are going to use this function. My UDFs: Barcode Libraries, Automate creation of any type of project folder, File Locking with Cooperative Semaphores, Inline binary files, Continue script after reboot, WinWaitMulti, Name Aggregator, Enigma, CornedBeef Hash Link to comment Share on other sites More sharing options...
Skitty Posted January 28, 2011 Author Share Posted January 28, 2011 (edited) When you try to encrypt an empty string, _StringEncrypt() is returning a 1 in @error. You need to skip encryption/decryption for blank lines if you are going to use this function.Going to test next day... update later and thank you! Edited January 28, 2011 by xJSLRx 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