metalicaman8 Posted May 14, 2008 Share Posted May 14, 2008 This is my first completed script that I am posting. It encrypts text and saves it to a file. When you open the file from within the script it remembers the encryption level and automatically sets it for decryption. It also uses a password. expandcollapse popup;==================================================== ;============= Encryption Tool With GUI ============= ;==================================================== ; AutoIt version: 3.0.103 ; Language: English ; Author: Wolvereness (with additions by metalicaman8) ; ; ---------------------------------------------------------------------------- ; Script Start ; ---------------------------------------------------------------------------- #include <guiconstants.au3> #include <string.au3> MsgBox(0, "Credit", "This was created from Wolvereness's 'Encryption Tool With GUI' in AutoIt3.") ;#include files for encryption and GUI constants ;~~ $WinMain = GuiCreate('Encryption tool', 625, 400) ; Creates window ;~~ $EditText = GuiCtrlCreateEdit('',5,5, 605,350) ; Creates main edit ;~~ $InputPass = GuiCtrlCreateInput('',5,360,100,20, 0x21) ; Creates the password box with blured/centered input ;~~ $InputLevel = GuiCtrlCreateInput(1, 110, 360, 50, 20, 0x2001) $UpDownLevel = GUICtrlSetLimit(GuiCtrlCreateUpDown($inputlevel),10,1) ; These two make the level input with the Up|Down ability ;~~ $EncryptButton = GuiCtrlCreateButton('Encrypt', 170, 360, 105, 35) $DecryptButton = GuiCtrlCreateButton('Decrypt', 285, 360, 105, 35) $Save = GUICtrlCreateButton("Save", 400, 360, 105, 35) $Open = GUICtrlCreateButton('Open', 515, 360, 105,35) ; Encryption/Decryption buttons ;~~ GUICtrlCreateLabel('Password', 5, 385) GuiCtrlCreateLabel('Level',110,385) ; Simple text labels so you know what is what ;~~ GuiSetState() ; Shows window ;~~ Do $Msg = GuiGetMsg() If $msg = $EncryptButton Then ; When you press Encrypt ;~~ GuiSetState(@SW_DISABLE,$WinMain) ; Stops you from changing anything ;~~ $string = GuiCtrlRead($EditText) ; Saves the editbox for later ;~~ GUICtrlSetData($EditText,'Please wait while the text is Encrypted/Decrypted.') ; Friendly message ;~~ GuiCtrlSetData($EditText,_StringEncrypt(1,$string,GuiCtrlRead($InputPass),GuiCtrlRead($InputLevel))) ; Calls the encryption. Sets the data of editbox with the encrypted string ;~~ GuiSetState(@SW_ENABLE,$WinMain) ; This turns the window back on ;~~ EndIf If $msg = $DecryptButton Then ; When you press Decrypt ;~~ GuiSetState(@SW_DISABLE,$WinMain) ; Stops you from changing anything ;~~ $string = GuiCtrlRead($EditText) ; Saves the editbox for later ;~~ GUICtrlSetData($EditText,'Please wait while the text is Encrypted/Decrypted.') ; Friendly message ;~~ GuiCtrlSetData($EditText,_StringEncrypt(0,$string,GuiCtrlRead($InputPass),GuiCtrlRead($InputLevel))) ; Calls the encryption. Sets the data of editbox with the encrypted string ;~~ GuiSetState(@SW_ENABLE,$WinMain) ; This turns the window back on ;~~ EndIf If $msg = $Save Then ;When you press Save ;~~ $name = FileSaveDialog("Save file", @ScriptDir, "Encrypted Text File (*.txe)") If @error<>1 Then $editedtext = GUICtrlRead($EditText) $level = GUICtrlRead($InputLevel) FileWrite($name,$editedtext&"|"& $level) EndIf EndIf If $msg = $Open Then ;When you press Open ;~~ $file = FileOpenDialog('Open file', @DesktopDir, 'Encrypted Text File (*.txe)') If @error<>1 Then $openedfile = FileRead($file) $openedfile = StringSplit($openedfile,"|") GUICtrlSetData($EditText,$openedfile[1]) StringInStr(FileRead($file),"|") GUICtrlSetData($InputLevel,$openedfile[2]) EndIf EndIf Until $msg = $GUI_EVENT_CLOSE; Continue loop untill window is closed [center]Take the Magic: The Gathering 'What Color Are You?' Quiz.[/center] 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