Jump to content
Sign in to follow this  
James

_Login

Recommended Posts

James

Hi all,

Something I found from my backup discs.

#NoTrayIcon

_Login("My Password", "Please enter a password", "password")

Func _Login($Title, $Prompt, $Password, $MaxAttempts = 3)
    $Attempts = 0
    Do
        $InputBoxAnswer = InputBox($Title, $Prompt, "", "*M", "-1", "-1", "-1", "-1")
        Select
            Case @error = 0;OK - The string returned is valid
                If $InputBoxAnswer == $Password Then
                    MsgBox(1024, "Password was correct!", "You typed the correct Password. You may access this file!"); What to do if password was entered correctly!
                    Exit
                Else
                    If $Attempts < $MaxAttempts - 1 And $MaxAttempts <> 1 Then
                        MsgBox(1024, "Password was wrong!", "You typed the Wrong Password. You may try again " & ($MaxAttempts - 1) - $Attempts & " time(s)"); What to do if password was not entered correctly!
                    Else
                        MsgBox(1024, "Password was wrong!", "Sorry, You can not access this file!"); What to do if password was not entered correctly!
                    EndIf
                    $Attempts += 1
                   ;Exit
                EndIf
                
            Case @error = 1;The Cancel button was pushed
                Exit
        EndSelect
    Until $Attempts = $MaxAttempts Or $InputBoxAnswer == $Password
EndFunc  ;==>Password

Could be useful.

James

Share this post


Link to post
Share on other sites
GEOSoft

Hi all,

Something I found from my backup discs.

#NoTrayIcon

_Login("My Password", "Please enter a password", "password")

Func _Login($Title, $Prompt, $Password, $MaxAttempts = 3)
    $Attempts = 0
    Do
        $InputBoxAnswer = InputBox($Title, $Prompt, "", "*M", "-1", "-1", "-1", "-1")
        Select
            Case @error = 0;OK - The string returned is valid
                If $InputBoxAnswer == $Password Then
                    MsgBox(1024, "Password was correct!", "You typed the correct Password. You may access this file!"); What to do if password was entered correctly!
                    Exit
                Else
                    If $Attempts < $MaxAttempts - 1 And $MaxAttempts <> 1 Then
                        MsgBox(1024, "Password was wrong!", "You typed the Wrong Password. You may try again " & ($MaxAttempts - 1) - $Attempts & " time(s)"); What to do if password was not entered correctly!
                    Else
                        MsgBox(1024, "Password was wrong!", "Sorry, You can not access this file!"); What to do if password was not entered correctly!
                    EndIf
                    $Attempts += 1
                  ;Exit
                EndIf
                
            Case @error = 1;The Cancel button was pushed
                Exit
        EndSelect
    Until $Attempts = $MaxAttempts Or $InputBoxAnswer == $Password
EndFunc ;==>Password

Could be useful.

James

I remember seeing this a long time back James. It's good but it may be better if you also added username in there. Instead if using a standard inputbox, just create a custom GUI with 2 input controls and 2 buttons.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
Yggdrasil

The problem I see with this script is that you take it for granted that the user of "_Login" provides the variable "$Password". While I'm by no means a coding expert I find this rather problematic because you would have to save this password somewhere in the .exe and it could easily be read by disassambling said .exe. If you would on the other hand save it in the registry/a file it wouldn't be safe either.

So you would have to chose a more secure approach for storing a password like encryption for the password and/or the work with hashes. But on the other hand: If someone is skilled enough to do this, I doubt he would require this sample script.

So this script isn't really safe or secure and everyone using it should keep this in mind.

Share this post


Link to post
Share on other sites
GEOSoft

The problem I see with this script is that you take it for granted that the user of "_Login" provides the variable "$Password". While I'm by no means a coding expert I find this rather problematic because you would have to save this password somewhere in the .exe and it could easily be read by disassambling said .exe. If you would on the other hand save it in the registry/a file it wouldn't be safe either.

So you would have to chose a more secure approach for storing a password like encryption for the password and/or the work with hashes. But on the other hand: If someone is skilled enough to do this, I doubt he would require this sample script.

So this script isn't really safe or secure and everyone using it should keep this in mind.

There is no such thing as fool-proof code. A bigger fool will always come along.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.