DirtDBaK Posted January 5, 2008 Share Posted January 5, 2008 yet i cant even find the "next" statementand now tis saying line 20 blah blah blahfunc_setuser($atmpt)error:"if"statement has no matching "endif" statementice avtually trid this and ti does have a end if wth is wrong with auto itnext isn't a actual statement like 'if' would bethe 'for' loop is formatted like soFor $Variable = Value To Value Step Value;Things to be repeatedNextThe next acts as an endif for an 'if' statement. But I think you are letting these other users show you code that is over your head. give me a little while and I will write you a very SIMPLE example... [center][/center] Link to comment Share on other sites More sharing options...
DirtDBaK Posted January 5, 2008 Share Posted January 5, 2008 I wrote you a small script that I tried to heavily comment.. And when it stores the password 'abcd' it looks like this FAD06017B84DD43F92ECB1F61C8FE5DE that way your operators cannot just read the INI Here is the code: expandcollapse popup;This help example by DBaK #include-once ;I use this line just so that I don't include files twice by acident and cause an error #include <String.au3> ;We need this file for the Encrypt/Decrypt #include <GUIConstants.au3> ;We need this file to create a GUI Global $INI = @ScriptDir & "\pswd.ini" ;Here we define what file our password is In Global $Section = 'Password' ;Here we define what section we will use in our ini Global $Key = 'Dust' ;Here we define which key we will want to use Global $EncryptKey = 'asdf' ;This is the encryption key Global $EncryptLevel = '2' ;This is our level of encryption #Region ### START Koda GUI section ### Form= Global $Form1 = GUICreate("MY Password Program", 176, 32, 193, 115) Global $Button1 = GUICtrlCreateButton("Store PSWD", 8, 0, 75, 25, 0) Global $Button2 = GUICtrlCreateButton("Login", 88, 0, 75, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $button1 _Store() Case $button2 _Login() EndSwitch WEnd Func _Store() ;This function will write our encrypted password $PSWD = InputBox( 'Store Password', 'New Password', '', '|' ) ;Help file will explain this ;I don't check to see if you pressed cancel but you can handel that $PSWD = _StringEncrypt ( 1, $PSWD, $EncryptKey , $EncryptLevel ) IniWrite( $INI, $SECTION, $KEY, $PSWD ) ;You can also use literal strings but to make this ;more dynamic I used varialbles EndFunc Func _Login() $Actual_Password = IniRead( $INI, $SECTION, $KEY, '' ) ;This will read the INI for a password If $Actual_Password = '' Then MsgBox(64, 'Error', 'No Password Stored' ) Return Endif $Actual_Password = _StringEncrypt ( 0, $Actual_Password, $EncryptKey , $EncryptLevel ) ;This will decrypt the text into the ;string you used to store it as. For $i = 1 to 3 step 1 ;this means that $i = 1 and it will exit the loop when $i = 3 and each time ;it loops through it will step/add +1 to $i $Temp = InputBox( 'Your Password', 'Login Password', '', '|' );Help file will explain this IF $temp = '' then Return ;If you dont type anything then just go back to the main loop If $temp <> $Actual_Password Then MsgBox(32, 'Error', 'Wrong password!' ) Else MsgBox(32,'YES!', 'Correct Password') Return ;Sends you back to the main loop Endif Next ;This loop makes it so that the user only has 3 tries to log in but ;if you take our the 'Next' line and the 'For $i = 1 to 3 step 1' line then they will only have one chance EndFunc You do not need to make an INI file, just hit store in this program and it will create it for you. Hope this helps [center][/center] Link to comment Share on other sites More sharing options...
corey822 Posted January 5, 2008 Author Share Posted January 5, 2008 I wrote you a small script that I tried to heavily comment.. And when it stores the password 'abcd' it looks like this FAD06017B84DD43F92ECB1F61C8FE5DE that way your operators cannot just read the INI Here is the code: expandcollapse popup;This help example by DBaK #include-once ;I use this line just so that I don't include files twice by acident and cause an error #include <String.au3> ;We need this file for the Encrypt/Decrypt #include <GUIConstants.au3> ;We need this file to create a GUI Global $INI = @ScriptDir & "\pswd.ini" ;Here we define what file our password is In Global $Section = 'Password' ;Here we define what section we will use in our ini Global $Key = 'Dust' ;Here we define which key we will want to use Global $EncryptKey = 'asdf' ;This is the encryption key Global $EncryptLevel = '2' ;This is our level of encryption #Region ### START Koda GUI section ### Form= Global $Form1 = GUICreate("MY Password Program", 176, 32, 193, 115) Global $Button1 = GUICtrlCreateButton("Store PSWD", 8, 0, 75, 25, 0) Global $Button2 = GUICtrlCreateButton("Login", 88, 0, 75, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $button1 _Store() Case $button2 _Login() EndSwitch WEnd Func _Store() ;This function will write our encrypted password $PSWD = InputBox( 'Store Password', 'New Password', '', '|' ) ;Help file will explain this ;I don't check to see if you pressed cancel but you can handel that $PSWD = _StringEncrypt ( 1, $PSWD, $EncryptKey , $EncryptLevel ) IniWrite( $INI, $SECTION, $KEY, $PSWD ) ;You can also use literal strings but to make this ;more dynamic I used varialbles EndFunc Func _Login() $Actual_Password = IniRead( $INI, $SECTION, $KEY, '' ) ;This will read the INI for a password If $Actual_Password = '' Then MsgBox(64, 'Error', 'No Password Stored' ) Return Endif $Actual_Password = _StringEncrypt ( 0, $Actual_Password, $EncryptKey , $EncryptLevel ) ;This will decrypt the text into the ;string you used to store it as. For $i = 1 to 3 step 1 ;this means that $i = 1 and it will exit the loop when $i = 3 and each time ;it loops through it will step/add +1 to $i $Temp = InputBox( 'Your Password', 'Login Password', '', '|' );Help file will explain this IF $temp = '' then Return ;If you dont type anything then just go back to the main loop If $temp <> $Actual_Password Then MsgBox(32, 'Error', 'Wrong password!' ) Else MsgBox(32,'YES!', 'Correct Password') Return ;Sends you back to the main loop Endif Next ;This loop makes it so that the user only has 3 tries to log in but ;if you take our the 'Next' line and the 'For $i = 1 to 3 step 1' line then they will only have one chance EndFunc You do not need to make an INI file, just hit store in this program and it will create it for you. Hope this helps ok thnz wow nicely done is there a way to add a user into that? cheers C.W C.Wnew rules:1.dont use plz in a post or title use please instead2.always use help file as it is now muchly over rated3. dont think where not watching u4.please wait 24 hours after last post ot bump XD i use to make that mistake Link to comment Share on other sites More sharing options...
DirtDBaK Posted January 5, 2008 Share Posted January 5, 2008 Sure Where it says $user = just change that to $user = Inputbox('User Name', 'User Name:','','|") Then you could store passwords for different users and login as different users.. Hope it Helps! [center][/center] Link to comment Share on other sites More sharing options...
corey822 Posted January 5, 2008 Author Share Posted January 5, 2008 Sure Where it says $user = just change that to $user = Inputbox('User Name', 'User Name:','','|") Then you could store passwords for different users and login as different users.. Hope it Helps! i cant find $user in your script? cheers C.W C.Wnew rules:1.dont use plz in a post or title use please instead2.always use help file as it is now muchly over rated3. dont think where not watching u4.please wait 24 hours after last post ot bump XD i use to make that mistake Link to comment Share on other sites More sharing options...
Triblade Posted January 18, 2008 Share Posted January 18, 2008 (edited) i cant find $user in your script?cheers C.WI couldent find it at first as well, but I saw there was no $user First replace all $Key with $user and then try again If you replace:Global $user = 'Dust' ;Here we define which key we will want to useWith:Global $user = Inputbox('User Name', 'User Name:','','|')The program will ask you for ur username before showing the GUI.It makes an .ini for every user login in and storing pwd's.Edit: In DBak's reply was a typo. the last " has to be a ' else you get an error. Edited January 18, 2008 by Triblade My active project(s): A-maze-ing generator (generates a maze) My archived project(s): Pong3 (Multi-pinger) 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