Jump to content

Password Prompt GUI


Recommended Posts

How do I validate the password the end user types and make sure it is complex 8 chars, one Capital and number?

; Get password to pass later in script

$user_input = InputBox("Checkpoint Charlie", "Please Enter Password for My_Special_Account Account", "", "*")

If $user_input = "" Then

MsgBox(4096, "Checkpoint Charlie", "Can't Continue without a Password!", 10)

Exit

EndIf

Link to comment
Share on other sites

heres something I did, you cant continue until password is confirmed

Do
$Pass = InputBox ("Password", "Please enter your password", "", "*M")
$Split = StringSplit ($Pass, "")
If $Split[0]
$ConfirmPass = InputBox ("Password", "Please Confirm your password", "", "*M")
If $Pass <> $ConfirmPass Then MsgBox (48, "Error", "Passwords do not match!!")
Until $Pass = $ConfirmPass

Edit: put in *M so pass cannot be ""

edit 2:

Do
$Pass = InputBox ("Password", "Please enter your password", "", "*M")
$Split = StringSplit ($Pass, "")
If $Split[0] < 8 Then
MsgBox (48, "Error", "Pass is less than 8 character!")
$ConfirmPass = ""
ContinueLoop
EndIf
$n = 0
$u = 0
For $i = 1 to $Split[0]
If StringIsDigit ($Split[$i]) = 1 Then $n = 1
If StringIsUpper ($Split[$i]) = 1 Then $u = 1
Next
If $n <> 1 then
MsgBox (48, "Error", "Pass contains no numbers!")
$ConfirmPass = ""
ContinueLoop
ElseIf $u <> 1 then
MsgBox (48, "Error", "Pass contains no capitals!")
$ConfirmPass = ""
ContinueLoop
EndIf
$ConfirmPass = InputBox ("Password", "Please Confirm your password", "", "*M")
If $Pass <> $ConfirmPass Then MsgBox (48, "Error", "Passwords do not match!!")
Until $Pass = $ConfirmPass
Edited by mdiesel
Link to comment
Share on other sites

heres something I did, you cant continue until password is confirmed

Do
$Pass = InputBox ("Password", "Please enter your password", "", "*M")
$Split = StringSplit ($Pass, "")
If $Split[0]
$ConfirmPass = InputBox ("Password", "Please Confirm your password", "", "*M")
If $Pass <> $ConfirmPass Then MsgBox (48, "Error", "Passwords do not match!!")
Until $Pass = $ConfirmPass

Edit: put in *M so pass cannot be ""

edit 2:

Do
$Pass = InputBox ("Password", "Please enter your password", "", "*M")
$Split = StringSplit ($Pass, "")
If $Split[0] < 8 Then
MsgBox (48, "Error", "Pass is less than 8 character!")
$ConfirmPass = ""
ContinueLoop
EndIf
$n = 0
$u = 0
For $i = 1 to $Split[0]
If StringIsDigit ($Split[$i]) = 1 Then $n = 1
If StringIsUpper ($Split[$i]) = 1 Then $u = 1
Next
If $n <> 1 then
MsgBox (48, "Error", "Pass contains no numbers!")
$ConfirmPass = ""
ContinueLoop
ElseIf $u <> 1 then
MsgBox (48, "Error", "Pass contains no capitals!")
$ConfirmPass = ""
ContinueLoop
EndIf
$ConfirmPass = InputBox ("Password", "Please Confirm your password", "", "*M")
If $Pass <> $ConfirmPass Then MsgBox (48, "Error", "Passwords do not match!!")
Until $Pass = $ConfirmPass
Right on the money, REALLY appreciated!!
Link to comment
Share on other sites

any one else interested, look at this nice little func i ended up with, you can use combinations of complexity, so you can use 5 for instance (no numbers needed), or just use 7.

Has someone released this kind of thing before? If not I think I'll improve this and make a nice little udf...

; Complexity
; 0 - No complexity
; 1 - Mandatory entry
; 2 - 8 letters min
; 4 - Numbers must be included
; 8 - Capitals must be included

_PasswordCreate (15)

Func _PasswordCreate ($Complexity)
   Local $Pass, $Split, $n, $u, $ConfirmPass, $m

If BitAND($complexity, 1) Then
   $m = "M"
Else
   $m = ""
EndIf
Do
   $Pass = InputBox ("Password", "Please enter your password", "", "*" & $m)
      If @Error Then Return SetError (1); Pass box cancelled
   $Split = StringSplit ($Pass, "")

   If BitAND($complexity, 2) Then
      If $Split[0] < 8 Then
         MsgBox (48, "Error", "Pass is less than 8 character!")
         $ConfirmPass = ""
         ContinueLoop
      EndIf
   EndIf
   If BitAND($complexity, 4) Then
      $n = 0
      For $i = 1 to $Split[0]
         If StringIsDigit ($Split[$i]) = 1 Then $n = 1
      Next
         If $n <> 1 then
            MsgBox (48, "Error", "Pass contains no numbers!")
            $ConfirmPass = ""
            ContinueLoop
         EndIf
   EndIf
   If BitAND($complexity, 8) Then
      $u = 0
      For $i = 1 to $Split[0]
         If StringIsUpper ($Split[$i]) = 1 Then $u = 1
      Next
         If $u <> 1 then
            MsgBox (48, "Error", "Pass contains no capitals!")
            $ConfirmPass = ""
            ContinueLoop
         EndIf
   EndIf
   $ConfirmPass = InputBox ("Password", "Please Confirm your password", "", "*")
      If $Pass <> $ConfirmPass Then MsgBox (48, "Error", "Passwords do not match!!")
Until $Pass = $ConfirmPass
Return $Pass
EndFunc
Edited by mdiesel
Link to comment
Share on other sites

i havent seen very many udf's like this.. pretty cool :D

Link to comment
Share on other sites

@mdiesel

Here's another method that you might want to fine tune and play with.

Global $sPass
$sUserPass = _PassWord()
If @Error Then
    MsgBox(0, "Error " & @Error, "No Password")
Else
    MsgBox(0, "Results", $sUserPass)
EndIf

Func _Password()
$sPass = ""
$sPass = InputBox("Password", "Please enter your password", "", "*")
If $sPass Then
    If StringLen($sPass) >= 8 Then
        $iValid = 0
        For $i = 1 To 3
            $iValid += _Check($i)
        Next
    ;MsgBox(0, "TEST", $iValid)
        If $iValid  <3 Then
            _Error()
            _Password()
        Else
            $sVerify = InputBox("Confirm Password", "Please enter your password again", "", "*")
            If NOT $sVerify Then Return SetError(1)
            If $sVerify == $sPass Then
            ;MSGBOX(0, "TEST 2", "Verified")
                Return $sPass
            Else
            ;MsgBox(0, "TEST 3", $sPass & @CRLF & $sVerify)
                _Password()
            EndIF
        EndIf
    Else
        _Error()
        _PassWord()
    EndIf
Else
    Return SetError(1)
EndIf

EndFunc

Func _Error()
    MsgBox(0,"Invalid Password", "The Password must be at least 8 Characters and contain" & _
            " a combination of Upper and Lower case letters with at least 1 number.")
EndFunc

Func _Check($iChk)
    Switch $iChk
        Case 1
            $sChk = "[a-z]"
        Case 2
            $sChk = "[A-Z]"
        Case 3
            $sChk = "[0-9]"
        Case Else
            Return 0
    EndSwitch
    
    If StringRegExp($SPass, $sChk) Then Return 1
    Return 0
EndFunc

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!"

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...