ChaosUltima Posted December 28, 2005 Share Posted December 28, 2005 I wonder if this question has been posted or not, if so, please redirect me to the topic please? Im rather new to autoit, and i dunno not to get data from a specified file. What i am trying to do is that in a GUI window, i have an input where i type in a password. Then i click a button to encrypt and save the password in text file. That i can do. But what i cant do is when the next time the program starts up, and it reaches that GUI, i cant make it check that file for the saved password, and input it in the GUI's input box. Or to put it simple, how to get data from a certain text file and decrypt it? Please, i really need help on this Link to comment Share on other sites More sharing options...
NegativeNrG Posted December 28, 2005 Share Posted December 28, 2005 wait, do you want to Get the text from the .txt file, and decrypt it THEN place the decrypted txt into the input box? you can look in the help file for GUIctrlsetdata() and filereadline or iniread. [size=20]My File Upload[/size]Register at my site and upload. Link to comment Share on other sites More sharing options...
ChaosUltima Posted December 28, 2005 Author Share Posted December 28, 2005 Yeah, i wanna get the data from a text file, decrypt it, then put the decrypted text in the input. FileRead or FileReadLine doesnt work, it only gets the amount of characters/lines from the text file. how do you get the data? like, what to put in GuiCtrlSetData("?") If possible, can tell me how to retrieve only a specific line of data from teh text file? like the text file has: line 1 line 2 line 3 and i wanna tak the "line 2" from the text file and leave the others alone.? Link to comment Share on other sites More sharing options...
Amen Posted December 28, 2005 Share Posted December 28, 2005 (edited) Hi,One way to save data is to write an ini Simple make a string with your Encrypted data and save it example: $Data=_StringEncrypt(1,GUICtrlRead($Input_1),$myPassword) $msg=IniWrite($iniFile,"OPTIONS","Data",$Data) when u wonna read this file read the ini and make a decryption of that example: $Data=IniRead($iniFile,"OPTIONS","Data","") $Data=_StringEncrypt(0,$Data,$myPassword) You can also say (before saving) $Data=_StringEncrypt(1,GUICtrlRead($Input_1),$myPassword) Edited December 28, 2005 by Amen Plugged ThoughtsQBsick? check my Old staff (New Launchers to Work with Windows.Thnx to Autoit!)Game Development ToolsPortes (A Backgammon game)Ball (An Arkanoid Style game)Au3? SecretProgz - Reveals Commands that can be used on your system CleanOut - Uninstall leftovers Enable windows XP Autologon. Stop Windows Auto Sharing your hard drives (C$,D$,etc) D-Link - Create a dynamic link.Useful for server shortcuts Fun - How would your name sounds in Japanese,Russian or Reventian? Fix_srt - Shift a subtitle (.srt) some secs +/- Link to comment Share on other sites More sharing options...
jonk Posted December 28, 2005 Share Posted December 28, 2005 maybe something like this? #include <GUIConstants.au3> #include <String.au3> ;Generated with Form Designer preview $Form1 = GUICreate("FooGui", 276, 60, 192, 125) $Input1 = GUICtrlCreateInput("", 16, 16, 129, 21) $Button1 = GUICtrlCreateButton("save", 150, 16, 60, 25) $Button2 = GUICtrlCreateButton("load", 215, 16, 60, 25) _getMyPasswd() GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button1 IniWrite ( @ScriptDir&"\myini.ini", "FOO", "passwd", _StringEncrypt(1,GuiCtrlRead($Input1),"mypass")) GuiCtrlSetData($input1,"") Case $msg = $Button2 _getMyPasswd() Case Else ;;;;;;; EndSelect WEnd Exit func _getMyPasswd() if FileExists ( @ScriptDir&"\myini.ini" ) Then $a_KeyValues = IniReadSection ( @ScriptDir&"\myini.ini", "FOO" ) $decryptedValue = _StringEncrypt ( 0,$a_KeyValues[1][1] , "mypass" ) GuiCtrlSetData($Input1,$decryptedValue) EndIf EndFunc Link to comment Share on other sites More sharing options...
ChrisL Posted December 28, 2005 Share Posted December 28, 2005 Something like this (untested) to read from a plain file $Readline = "2" $logfile = "textfile.txt" $File = FileOpen ( $Logfile, 0) $Linecount = 0 While 1 $line = FileReadLine($File) If @error = -1 Then ExitLoop $linecount = $linecount + 1 IF $Linecount = $Readline then $StringtoDecrypt = $line Wend FileClose ( $File ) ;put your decrypt here $StringtoDecrypt holds line $Readline (2 in this case) [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
ChaosUltima Posted December 28, 2005 Author Share Posted December 28, 2005 Great! It works! Thanks guys! Link to comment Share on other sites More sharing options...
jonk Posted December 28, 2005 Share Posted December 28, 2005 (edited) Something like this (untested) to read from a plain file [/code] $Readline = "2" $logfile = "textfile.txt" $File = FileOpen ( $Logfile, 0) $Linecount = 0 While 1 $line = FileReadLine($File) If @error = -1 Then ExitLoop $linecount = $linecount + 1 IF $Linecount = $Readline then $StringtoDecrypt = $line Wend FileClose ( $File ) ;put your decrypt here $StringtoDecrypt holds line $Readline (2 in this case) if you know the line in which is the String to decrypt you do not need a loop $Readline = "2" $logfile = "textfile.txt" $File = FileOpen ( $Logfile, 0) $line = FileReadLine($File,$Readline) FileClose ( $File ) $decryptedValue = _StringEncrypt ( 0,$line , "mypass" ) Edited December 28, 2005 by jonk Link to comment Share on other sites More sharing options...
ChaosUltima Posted December 28, 2005 Author Share Posted December 28, 2005 func _getMyPasswd() if FileExists ( @ScriptDir&"\myini.ini" ) Then $a_KeyValues = IniReadSection ( @ScriptDir&"\myini.ini", "FOO" ) $decryptedValue = _StringEncrypt ( 0,$a_KeyValues[1][1], "mypass" ) GuiCtrlSetData($Input1,$decryptedValue) EndIf EndFunc What are the 2 [1] values for? Link to comment Share on other sites More sharing options...
ChrisL Posted December 28, 2005 Share Posted December 28, 2005 if you know the line in which is the String to decrypt you do not need a loop Oh yeah.. I've only ever used it in a loop to find a matched string, cheers [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
jonk Posted December 28, 2005 Share Posted December 28, 2005 What are the 2 [1] values for? [sectionName] Key=Value $a_KeyValues[1][1] -> 1st Key in the Section $a_KeyValues[1][1] -> 1st Value in the Section The number of elements returned will be in $result[0][0]. 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