epicfail Posted September 15, 2009 Share Posted September 15, 2009 hi i wouldlike to know how i would encrupt my ini file well at least my user name or passwords in it and then be able to deencrypt them so it can read it. I want to be able to do this so that other users cant open the ini file and see the passwords. IniWrite(@ScriptDir & "\settigs.ini", "Email & Password", "Email", "Email") IniWrite(@ScriptDir & "\settings.ini", "Email & Password", "Password", "Password") IniWrite(@ScriptDir & "\settings.ini", "CheckBox", "Save Email & Password", "No") IniRead(@ScriptDir & "\settings.ini", "Email & Password", "Email", "") IniRead(@ScriptDir & "\settings.ini", "Email & Password", "Password", "") IniRead(@ScriptDir & "\settings.ini", "CheckBox", "Save Email & Password", "") Link to comment Share on other sites More sharing options...
epicfail Posted September 15, 2009 Author Share Posted September 15, 2009 (edited) i know about _StringEncrypt but im not sure how to use it to read and write the ini Edited September 15, 2009 by epicfail Link to comment Share on other sites More sharing options...
jvanegmond Posted September 15, 2009 Share Posted September 15, 2009 1. Decrypt file before use. 2. Use. 3. Encrypt file after use. I have not tested this, if it does not work your next task is to fix it. Please don't came back saying "it no work 4 me" ; Decrypt ini file before use $data = FileRead(@ScriptDir & "\settings.ini") $decdata = _StringEncrypt(0, $data, "Password") $h = FileOpen(@ScriptDir & "\settings.ini", 2) FileWrite($h, $decdata) FileClose($h) IniWrite(@ScriptDir & "\settigs.ini", "Email & Password", "Email", "Email") IniWrite(@ScriptDir & "\settings.ini", "Email & Password", "Password", "Password") IniWrite(@ScriptDir & "\settings.ini", "CheckBox", "Save Email & Password", "No") IniRead(@ScriptDir & "\settings.ini", "Email & Password", "Email", "") IniRead(@ScriptDir & "\settings.ini", "Email & Password", "Password", "") IniRead(@ScriptDir & "\settings.ini", "CheckBox", "Save Email & Password", "") ; Encrypt the ini file after use $data = FileRead(@ScriptDir & "\settings.ini") $encdata = _StringEncrypt(1, $data, "Password") $h = FileOpen(@ScriptDir & "\settings.ini", 2) FileWrite($h, $encdata) FileClose($h) github.com/jvanegmond Link to comment Share on other sites More sharing options...
GodlessSinner Posted September 15, 2009 Share Posted September 15, 2009 This simple example may help you: expandcollapse popup;Codded by Godless(10.08.09). #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_outfile_type=a3x #AutoIt3Wrapper_Compression=0 #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_Run_AU3Check=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <ProgressConstants.au3> #include <GuiListView.au3> #Include <String.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> ;#RequireAdmin Global $string[100], $ListView1, $Item, $shown = False, $Saving = "", $file,$Progress1,$SaveListTo, $ListEmpty = True $mainpassword = InputBox("Enter password to login", "Enter your password below:", "", "*") If $mainpassword = "123" Then ; type your password here, and remember it:)Also it will be used for encryption! main() Else Exit EndIf Func main() #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 484, 265, 409, 526) $ListView1 = GUICtrlCreateListView("Program name|Password|Location", 16, 16, 457, 177, -1, BitOR($WS_EX_CLIENTEDGE,$LVS_EX_CHECKBOXES)) $CP = GUICtrlCreateButton("Change password", 168, 200, 65, 49, $BS_MULTILINE) GUICtrlSetState($CP, $GUI_DISABLE) $pass = GUICtrlCreateInput("Input1", 16, 200, 145, 21) $passconf = GUICtrlCreateInput("Input2", 16, 224, 145, 21) $Save = GUICtrlCreateButton("Save settings", 240, 200, 65, 49, $BS_MULTILINE) GUICtrlSetState(-1, $GUI_DISABLE) $Load = GUICtrlCreateButton("Load list form file", 312, 200, 65, 49, BitOR($BS_CENTER,$BS_MULTILINE)) $SaveTo = GUICtrlCreateButton("Save encrypted list to file", 384, 200, 89, 49, $BS_MULTILINE) GUICtrlSetState(-1, $GUI_DISABLE) $ListView1context = GUICtrlCreateContextMenu($ListView1) $Add = GUICtrlCreateMenuItem("Add...", $ListView1context) $Clear = GUICtrlCreateMenuItem("Clear list", $ListView1context) $Progress1 = GUICtrlCreateProgress(16, 256, 457, 9) GUICtrlSetState(-1,$GUI_HIDE) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 ;Sleep(100) If GUICtrlRead($pass) = GUICtrlRead($passconf) And(GUICtrlRead($pass)<>"" And GUICtrlRead($passconf)<>"") And $shown = False And _GUICtrlListView_GetItemCount($ListView1) > "0" Then GUICtrlSetState($CP, $GUI_ENABLE) $shown = True ElseIf GUICtrlRead($pass) <> GUICtrlRead($passconf) And(GUICtrlRead($pass)<>"" And GUICtrlRead($passconf)<>"") And $shown = True And _GUICtrlListView_GetItemCount($ListView1) > "0" Then GUICtrlSetState($CP, $GUI_DISABLE) $shown = False EndIf If _GUICtrlListView_GetItemCount($ListView1) > "0" And $ListEmpty = True Then GUICtrlSetState($Save, $GUI_ENABLE) GUICtrlSetState($SaveTo, $GUI_ENABLE) $ListEmpty = False ElseIf _GUICtrlListView_GetItemCount($ListView1) = "0" And $ListEmpty = False Then GUICtrlSetState($Save, $GUI_DISABLE) GUICtrlSetState($SaveTo, $GUI_DISABLE) $ListEmpty = True EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Add $AddToList = FileOpenDialog("Select file for add to list...", @DesktopDir & "\", "Any files(*.*)", 1,"",$Form1) If $AddToList <> "" Then $string = StringSplit($AddToList,"\") $filename = StringLen($string[$string[0]]) $location = StringTrimRight($AddToList, $filename) GUICtrlCreateListViewItem($string[$string[0]] & "||" & $location, $ListView1) EndIf Case $Clear $cnt = _GUICtrlListView_GetItemCount($ListView1) If $cnt > "0" Then $ms = MsgBox(4,"Confirm action","Are you sure want ot delete all(" & $cnt & ") items?","",$Form1) If $ms = 6 Then _GUICtrlListView_DeleteAllItems($ListView1) EndIf EndIf Case $CP $cnt = _GUICtrlListView_GetItemCount($ListView1) For $i = 0 To $cnt Step 1 If _GUICtrlListView_GetItemChecked($ListView1,$i) Then $Item = _GUICtrlListView_GetItemTextArray($ListView1,$i) _GUICtrlListView_SetItemText($ListView1, $i, $Item[1] & "|" & GUICtrlRead($pass) & "|" & $Item[3],-1) EndIf Next Case $Save If $SaveListTo <> "" Then SaveList($SaveListTo) EndIf Case $Load $SaveListTo = FileOpenDialog("Select file that contains encrypted passwods...", @DesktopDir & "\", "Password lists (*.pwl)", 1,"",$Form1) If $SaveListTo <> "" Then $From = $SaveListTo LoadList($From) EndIf Case $SaveTo $SaveListTo = FileSaveDialog("Select file to save data in...", @DesktopDir, "Password lists (.pwl)","","*.pwl", $Form1) If $SaveListTo <> "" Then SaveList($SaveListTo) EndIf EndSwitch WEnd EndFunc Func SaveList($SaveListTo) FileDelete ($SaveListTo) $file = FileOpen($SaveListTo, 1) If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Else GUICtrlSetState($Progress1,$GUI_SHOW) $cnt = _GUICtrlListView_GetItemCount($ListView1) For $i = 0 To $cnt-1 Step 1 GUICtrlSetData($Progress1, 100/($cnt-1)*$i) $line = _StringEncrypt(1, _GUICtrlListView_GetItemTextString($ListView1,$i), $mainpassword) FileWrite($file, $line & @CRLF) Next FileClose($file) Sleep(600) GUICtrlSetState($Progress1,$GUI_HIDE) EndIf EndFunc Func LoadList($From) $file = FileOpen($From, 0) While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop GUICtrlCreateListViewItem(_StringEncrypt(0, $line, $mainpassword), $ListView1) Wend FileClose($file) EndFunc _____________________________________________________________________________ Link to comment Share on other sites More sharing options...
epicfail Posted September 15, 2009 Author Share Posted September 15, 2009 thanks guys that realy helped just what i needed 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