Jfish Posted May 5, 2015 Share Posted May 5, 2015 Hello all. I was playing around with encrypt.au3 and thought it would be neat to build an executable that could extract and decrypt an encrypted file (sort of like an option in PGP if you have ever used that before). I had to think on the issue of installing the file in the exe because you can't use variable path names. The approach I came up with may not be the best - others may have much better ideas - but I thought I would share it nonetheless in case anyone finds it interesting.expandcollapse popup;********************************************* ; Example script ; ENCRYPT A FILE INTO A SELF-EXTRACTING EXE ; by: JFish ; ;******************************************** #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Crypt.au3> ; will be used for the encryption #include <File.au3> ; will be used to manipulate au3 file before we compile #Region ### START Koda GUI section ### Form=C:\Users\RC01712\Documents\Scripts\Encrypt Tool\encrypt_GUI.kxf $Form1 = GUICreate("Form1", 657, 244, 192, 132) $sourceInput = GUICtrlCreateInput("", 144, 48, 337, 24) $sourceBtn = GUICtrlCreateButton("Browse", 40, 48, 89, 25) $encryptBtn = GUICtrlCreateButton("Encrypt", 224, 128, 145, 33) $passwordInput = GUICtrlCreateInput("", 144, 80, 337, 24) $Label1 = GUICtrlCreateLabel("Password", 40, 80, 73, 24) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $decryptBtn = GUICtrlCreateButton("Decrypt", 224, 176, 145, 33) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ; var declaration for global scope dim $sourceFile, $password, $filename, $filenameRoot, $fileExtension, $publicEncFileNameFullPath, $publicEncFileName ; select a source file that we want to encrypt func _selectFile() GUICtrlSetData($sourceInput,"") $filename="" $sourceFile=FileOpenDialog("Please select a file to encrypt",@ScriptDir,"All (*.*)") $dirLen=stringlen(@WorkingDir)+1 ;grab the file name $filename=StringTrimLeft($sourceFile,$dirLen) local $firstDot=stringinstr($filename,".",0,-1) ;grab the file root name without the extension $filenameRoot=stringtrimright($filename,stringlen($filename)-$firstDot+1) ;grab the file extension $fileExtension=stringtrimleft($filename,$firstDot-1) ;MsgBox("","",$fileExtension) GUICtrlSetData($sourceInput,$sourceFile) EndFunc func _encrypt() $password = GUICtrlRead($passwordInput) if $password="" then MsgBox("","","please enter a password") EndIf ; encrypt the file NOTE: method in example of AES 256 is hard coded $result =_Crypt_EncryptFile($sourceFile,@ScriptDir&"\"&$filenameRoot&"_enc"&$fileExtension,$password,$CALG_AES_256) ; if the encryptions works ... if $result=True Then ; set the full path name to the file including the new "_enc" showing that it is encrypted $publicEncFileNameFullPath=@ScriptDir&"\"&$filenameRoot&"_enc"&$fileExtension ; setr the name of the encrypted file without the path $publicEncFileName=$filenameRoot&"_enc"&$fileExtension ; call the function to create the exe _createEXE($publicEncFileName,$publicEncFileName) else MsgBox("","","encryption error") EndIf MsgBox("","Encrypt status",$result) EndFunc func _createEXE($publicEncFileNameFullPath,$publicEncFileName) ;***************************************************************** ; This functions writes an au3 file that will get compiled and become our ; 'self extracting' encrypted file and program to decrypt ; The biggest issue is embedding the encrypted file with fileinstall ; b/c it does not take variable path names ;****************************************************************** ; craete an INI file with the full path name and file name of the encrypted file IniWrite(@ScriptDir&"\temp.ini","filedata","filename",$publicEncFileName) IniWrite(@ScriptDir&"\temp.ini","filedata","filepath",@ScriptDir&"\"&$publicEncFileName) ; stuff our au3 script into a variable called "wrapper" ; NOTE: there are two spots called "REPLACEME" and "REPLACEFILENAME" that will get replaced with ini text $wrapper='#include <Crypt.au3>'&@crlf& _ 'local $readFileName="REPLACEFILENAME"'&@crlf& _ 'MsgBox("","",$readFileName)'&@crlf& _ 'if FileExists(@ScriptDir&"\"&$readFileName) Then'&@crlf& _ 'Else'&@crlf& _ 'FileInstall("REPLACEME",@ScriptDir&"\"&$readFileName,1)'&@crlf& _ 'EndIf'&@crlf& _ '$passkey=InputBox("Please enter the decryption password","PASSWORD","","*",400,150)' &@crlf& _ 'local $newfilename=stringreplace($readFileName,"_enc","_dec")'&@crlf& _ '$firstDot=stringinstr($readFileName,".",0,-1)'&@crlf& _ '$fileExtension=stringtrimleft($readFileName,$firstDot-1)'&@crlf& _ 'if _Crypt_DecryptFile($readFileName, @ScriptDir&"\"&$newfilename&$fileExtension, $passkey, $CALG_AES_256) Then'&@crlf& _ 'Else'&@crlf& _ ' MsgBox("","","invalid password")'&@crlf& _ ' Exit'&@crlf& _ 'EndIf' ; open a new file for our "standalone" decryption program $tempFile=fileopen(@ScriptDir&"\standalone.au3",2) FileWrite($tempFile,$wrapper) FileClose($tempFile) ;after the au3 file is created read in the filename of the file to install and replace the text $readFileName=IniRead(@ScriptDir&"\temp.ini","filedata","filename","decryptedfile.txt") _ReplaceStringInFile (@ScriptDir&"\standalone.au3", "REPLACEFILENAME",$readFileName) ; after the au3 file is created read in the full path of the file to install and replace the text in au3 local $readFilePath=IniRead(@ScriptDir&"\temp.ini","filedata","filepath","default") _ReplaceStringInFile (@ScriptDir&"\standalone.au3", "REPLACEME",$readFilePath) ;compile the au3 file into an executable using the command line ShellExecuteWait("Aut2exe.exe"," /in standalone.au3 /out "&$filenameRoot&".exe",@ScriptDir) ;delete the temporary au3 file FileDelete(@ScriptDir&"\standalone.au3") EndFunc ;************************************************* ; This function will decrypt the file from the UI ; used to create the encrypted file (make sure you ; select the new name with the _enc first ;************************************************ func _decrypt() $password = GUICtrlRead($passwordInput) if $password="" then MsgBox("","","please enter a password") EndIf local $newfilename=stringreplace($filenameRoot,"_enc","_dec") $result=_Crypt_DecryptFile($sourceFile, @ScriptDir&"\"&$newfilename&$fileExtension, $password, $CALG_AES_256) MsgBox("","decrypt status",$result) EndFunc While 1 $nMsg = GUIGetMsg() Switch $nMsg case $sourceBtn _selectFile() case $encryptBtn _encrypt() case $decryptBtn _decrypt() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd encrypt2exe.au3 Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt Link to comment Share on other sites More sharing options...
guinness Posted May 6, 2015 Share Posted May 6, 2015 Quite a few bugs in that code, first one to stand out is _decrypt() where you check if the password is empty, display a message box and then continue to decrypt. Same for _encrypt(). Also Dim is outdated in AutoIt with Local and Global being used in favour of. Then little language changes such as If $variable = True Then can just be If $variable Then, less typing is what we like! UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Jfish Posted May 6, 2015 Author Share Posted May 6, 2015 Thanks for the feedback I will address those bugs shortly. I also appreciate the info on the latest techniques. Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt Link to comment Share on other sites More sharing options...
Jfish Posted May 6, 2015 Author Share Posted May 6, 2015 Here is a revised version incorporating your comments / suggestions:expandcollapse popup;********************************************* ; Example script ; ENCRYPT A FILE INTO A SELF-EXTRACTING EXE ; by: JFish ; ;******************************************** #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Crypt.au3> ; will be used for the encryption #include <File.au3> ; will be used to manipulate au3 file before we compile #Region ### START Koda GUI section ### Form=C:\Users\RC01712\Documents\Scripts\Encrypt Tool\encrypt_GUI.kxf $Form1 = GUICreate("Form1", 657, 244, 192, 132) $sourceInput = GUICtrlCreateInput("", 144, 48, 337, 24) $sourceBtn = GUICtrlCreateButton("Browse", 40, 48, 89, 25) $encryptBtn = GUICtrlCreateButton("Encrypt", 224, 128, 145, 33) $passwordInput = GUICtrlCreateInput("", 144, 80, 337, 24) $Label1 = GUICtrlCreateLabel("Password", 40, 80, 73, 24) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $decryptBtn = GUICtrlCreateButton("Decrypt", 224, 176, 145, 33) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ; var declaration for global scope global $sourceFile, $password, $filename, $filenameRoot, $fileExtension, $publicEncFileNameFullPath, $publicEncFileName ; select a source file that we want to encrypt func _selectFile() GUICtrlSetData($sourceInput,"") $filename="" $sourceFile=FileOpenDialog("Please select a file to encrypt",@ScriptDir,"All (*.*)") $dirLen=stringlen(@WorkingDir)+1 ;grab the file name $filename=StringTrimLeft($sourceFile,$dirLen) $firstDot=stringinstr($filename,".",0,-1) ;grab the file root name without the extension $filenameRoot=stringtrimright($filename,stringlen($filename)-$firstDot+1) ;grab the file extension $fileExtension=stringtrimleft($filename,$firstDot-1) ;MsgBox("","",$fileExtension) GUICtrlSetData($sourceInput,$sourceFile) EndFunc func _encrypt() $password = GUICtrlRead($passwordInput) if $password="" then MsgBox("","","please enter a password") Else ; encrypt the file NOTE: method in example of AES 256 is hard coded $result =_Crypt_EncryptFile($sourceFile,@ScriptDir&"\"&$filenameRoot&"_enc"&$fileExtension,$password,$CALG_AES_256) ; if the encryptions works ... if $result Then ; set the full path name to the file including the new "_enc" showing that it is encrypted $publicEncFileNameFullPath=@ScriptDir&"\"&$filenameRoot&"_enc"&$fileExtension ; setr the name of the encrypted file without the path $publicEncFileName=$filenameRoot&"_enc"&$fileExtension ; call the function to create the exe _createEXE($publicEncFileName,$publicEncFileName) else MsgBox("","","encryption error") EndIf MsgBox("","Encrypt status",$result) EndIf EndFunc func _createEXE($publicEncFileNameFullPath,$publicEncFileName) ;***************************************************************** ; This functions writes an au3 file that will get compiled and become our ; 'self extracting' encrypted file and program to decrypt ; The biggest issue is embedding the encrypted file with fileinstall ; b/c it does not take variable path names ;****************************************************************** ; craete an INI file with the full path name and file name of the encrypted file IniWrite(@ScriptDir&"\temp.ini","filedata","filename",$publicEncFileName) IniWrite(@ScriptDir&"\temp.ini","filedata","filepath",@ScriptDir&"\"&$publicEncFileName) ; stuff our au3 script into a variable called "wrapper" ; NOTE: there are two spots called "REPLACEME" and "REPLACEFILENAME" that will get replaced with ini text $wrapper='#include <Crypt.au3>'&@crlf& _ 'local $readFileName="REPLACEFILENAME"'&@crlf& _ 'MsgBox("","",$readFileName)'&@crlf& _ 'if FileExists(@ScriptDir&"\"&$readFileName) Then'&@crlf& _ 'Else'&@crlf& _ 'FileInstall("REPLACEME",@ScriptDir&"\"&$readFileName,1)'&@crlf& _ 'EndIf'&@crlf& _ '$passkey=InputBox("Please enter the decryption password","PASSWORD","","*",400,150)' &@crlf& _ 'local $newfilename=stringreplace($readFileName,"_enc","_dec")'&@crlf& _ '$firstDot=stringinstr($readFileName,".",0,-1)'&@crlf& _ '$fileExtension=stringtrimleft($readFileName,$firstDot-1)'&@crlf& _ 'if _Crypt_DecryptFile($readFileName, @ScriptDir&"\"&$newfilename&$fileExtension, $passkey, $CALG_AES_256) Then'&@crlf& _ 'Else'&@crlf& _ ' MsgBox("","","invalid password")'&@crlf& _ ' Exit'&@crlf& _ 'EndIf' ; open a new file for our "standalone" decryption program $tempFile=fileopen(@ScriptDir&"\standalone.au3",2) FileWrite($tempFile,$wrapper) FileClose($tempFile) ;after the au3 file is created read in the filename of the file to install and replace the text $readFileName=IniRead(@ScriptDir&"\temp.ini","filedata","filename","decryptedfile.txt") _ReplaceStringInFile (@ScriptDir&"\standalone.au3", "REPLACEFILENAME",$readFileName) ; after the au3 file is created read in the full path of the file to install and replace the text in au3 local $readFilePath=IniRead(@ScriptDir&"\temp.ini","filedata","filepath","default") _ReplaceStringInFile (@ScriptDir&"\standalone.au3", "REPLACEME",$readFilePath) ;compile the au3 file into an executable using the command line ShellExecuteWait("Aut2exe.exe"," /in standalone.au3 /out "&$filenameRoot&".exe",@ScriptDir) ;delete the temporary au3 file FileDelete(@ScriptDir&"\standalone.au3") EndFunc ;************************************************* ; This function will decrypt the file from the UI ; used to create the encrypted file (make sure you ; select the new name with the _enc first ;************************************************ func _decrypt() $password = GUICtrlRead($passwordInput) if $password="" then MsgBox("","","please enter a password") Else local $newfilename=stringreplace($filenameRoot,"_enc","_dec") $result=_Crypt_DecryptFile($sourceFile, @ScriptDir&"\"&$newfilename&$fileExtension, $password, $CALG_AES_256) ;MsgBox("","decrypt status",$result) EndIf EndFunc While 1 $nMsg = GUIGetMsg() Switch $nMsg case $sourceBtn _selectFile() case $encryptBtn _encrypt() case $decryptBtn _decrypt() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd encrypt2exe.au3 Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt Link to comment Share on other sites More sharing options...
Jfish Posted May 13, 2015 Author Share Posted May 13, 2015 I actually tested this thing ... the EXE needed a lot of work. Now it will delete an unsuccessful file and delete the encrypted version of the file after it is successful. expandcollapse popup;********************************************* ; Example script ; ENCRYPT A FILE INTO A SELF-EXTRACTING EXE ; by: JFish ; ;******************************************** #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Crypt.au3> ; will be used for the encryption #include <File.au3> ; will be used to manipulate au3 file before we compile #Region ### START Koda GUI section ### Form=C:\Users\RC01712\Documents\Scripts\Encrypt Tool\encrypt_GUI.kxf $Form1 = GUICreate("Form1", 657, 244, 192, 132) $sourceInput = GUICtrlCreateInput("", 144, 48, 337, 24) $sourceBtn = GUICtrlCreateButton("Browse", 40, 48, 89, 25) $encryptBtn = GUICtrlCreateButton("Encrypt", 224, 128, 145, 33) $passwordInput = GUICtrlCreateInput("", 144, 80, 337, 24) $Label1 = GUICtrlCreateLabel("Password", 40, 80, 73, 24) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $decryptBtn = GUICtrlCreateButton("Decrypt", 224, 176, 145, 33) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ; var declaration for global scope global $sourceFile, $password, $filename, $filenameRoot, $fileExtension, $publicEncFileNameFullPath, $publicEncFileName ; select a source file that we want to encrypt func _selectFile() GUICtrlSetData($sourceInput,"") $filename="" $sourceFile=FileOpenDialog("Please select a file to encrypt",@ScriptDir,"All (*.*)") $dirLen=stringlen(@WorkingDir)+1 ;grab the file name $filename=StringTrimLeft($sourceFile,$dirLen) $firstDot=stringinstr($filename,".",0,-1) ;grab the file root name without the extension $filenameRoot=stringtrimright($filename,stringlen($filename)-$firstDot+1) ;grab the file extension $fileExtension=stringtrimleft($filename,$firstDot-1) ;MsgBox("","",$fileExtension) GUICtrlSetData($sourceInput,$sourceFile) EndFunc func _encrypt() $password = GUICtrlRead($passwordInput) if $password="" then MsgBox("","","please enter a password") Else ; encrypt the file NOTE: method in example of AES 256 is hard coded $result =_Crypt_EncryptFile($sourceFile,@ScriptDir&"\"&$filenameRoot&"_enc"&$fileExtension,$password,$CALG_AES_256) ; if the encryptions works ... if $result Then ; set the full path name to the file including the new "_enc" showing that it is encrypted $publicEncFileNameFullPath=@ScriptDir&"\"&$filenameRoot&"_enc"&$fileExtension ; setr the name of the encrypted file without the path $publicEncFileName=$filenameRoot&"_enc"&$fileExtension ; call the function to create the exe _createEXE($publicEncFileName,$publicEncFileName) else MsgBox("","","encryption error") EndIf ;MsgBox("","Encrypt status",$result) EndIf EndFunc func _createEXE($publicEncFileNameFullPath,$publicEncFileName) ;***************************************************************** ; This functions writes an au3 file that will get compiled and become our ; 'self extracting' encrypted file and program to decrypt ; The biggest issue is embedding the encrypted file with fileinstall ; b/c it does not take variable path names ;****************************************************************** ; craete an INI file with the full path name and file name of the encrypted file IniWrite(@ScriptDir&"\temp.ini","filedata","filename",$publicEncFileName) IniWrite(@ScriptDir&"\temp.ini","filedata","filepath",@ScriptDir&"\"&$publicEncFileName) ; stuff our au3 script into a variable called "wrapper" ; NOTE: there are two spots called "REPLACEME" and "REPLACEFILENAME" that will get replaced with ini text $wrapper='#include <Crypt.au3>'&@crlf& _ 'local $readFileName="REPLACEFILENAME"'&@crlf& _ 'if FileExists(@ScriptDir&"\"&$readFileName) Then'&@crlf& _ 'Else'&@crlf& _ 'FileInstall("REPLACEME",@ScriptDir&"\"&$readFileName,1)'&@crlf& _ 'EndIf'&@crlf& _ 'local $newfilename=stringreplace($readFileName,"_enc","_dec")'&@crlf& _ '$firstDot=stringinstr($readFileName,".",0,-1)'&@crlf& _ '$fileExtension=stringtrimleft($readFileName,$firstDot-1)'&@crlf& _ '$passkey=InputBox("Please enter the decryption password","PASSWORD","","*",400,150)' &@crlf& _ 'if _Crypt_DecryptFile($readFileName, @ScriptDir&"\"&$newfilename, $passkey, $CALG_AES_256) Then'&@crlf& _ ' FileDelete(@ScriptDir&"\"&$readFileName)'&@crlf& _ 'Else'&@crlf& _ ' FileDelete(@ScriptDir&"\"&$newfilename)'&@crlf& _ ' MsgBox("","","invalid password")'&@crlf& _ ' Exit'&@crlf& _ 'EndIf' ; open a new file for our "standalone" decryption program $tempFile=fileopen(@ScriptDir&"\standalone.au3",2) FileWrite($tempFile,$wrapper) FileClose($tempFile) ;after the au3 file is created read in the filename of the file to install and replace the text $readFileName=IniRead(@ScriptDir&"\temp.ini","filedata","filename","decryptedfile.txt") _ReplaceStringInFile (@ScriptDir&"\standalone.au3", "REPLACEFILENAME",$readFileName) ; after the au3 file is created read in the full path of the file to install and replace the text in au3 local $readFilePath=IniRead(@ScriptDir&"\temp.ini","filedata","filepath","default") _ReplaceStringInFile (@ScriptDir&"\standalone.au3", "REPLACEME",$readFilePath) ;compile the au3 file into an executable using the command line ShellExecuteWait("Aut2exe.exe"," /in standalone.au3 /out "&$filenameRoot&".exe",@ScriptDir) ;delete the temporary au3 file FileDelete(@ScriptDir&"\standalone.au3") EndFunc ;************************************************* ; This function will decrypt the file from the UI ; used to create the encrypted file (make sure you ; select the new name with the _enc first ;************************************************ func _decrypt() $password = GUICtrlRead($passwordInput) if $password="" then MsgBox("","","please enter a password") Else local $newfilename=stringreplace($filenameRoot,"_enc","_dec") $result=_Crypt_DecryptFile($sourceFile, @ScriptDir&"\"&$newfilename&$fileExtension, $password, $CALG_AES_256) ;MsgBox("","decrypt status",$result) EndIf EndFunc While 1 $nMsg = GUIGetMsg() Switch $nMsg case $sourceBtn _selectFile() case $encryptBtn _encrypt() case $decryptBtn _decrypt() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt 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