Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Verifying Password naming conventions
Message
From
16/04/2010 06:37:41
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
15/04/2010 20:04:03
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Vista
Miscellaneous
Thread ID:
01460453
Message ID:
01460495
Views:
58
>How can I verify passwords the following naming conventions:
>
>• It must be at least 10 characters
> • It must contain at least 2 special characters: !@#$%^&*_-+=':;.,
> • It must contain at least 2 numbers
> • It must contain at least 2 uppercase and 2 lowercase letters
> • It must not be one of your last 10 passwords.
> • It IS case sensitive

You can do something like this:
Procedure ValidatePassword(tcPassword)
  If Len(m.tcPassword) < 10
    Return .F.
  Endif
  Local ix, IsValid, lcChar, punctuation, digit, upCase, lowCase
  Store 0 To punctuation, digit, upCase, lowCase
  For ix=1 To Len(m.tcPassword)
    lcChar = Substr(m.tcPassword,m.ix,1)
    Do Case
      Case m.lcChar $ "!@#$%^&*_-+=':;.,"
        punctuation = m.punctuation + 1
      Case Isalpha(m.lcChar)
        If Isupper(m.lcChar)
          upCase = m.upCase + 1
        Else
          lowCase = m.lowCase + 1
        Endif
      Case Isdigit(m.lcChar)
        digit = m.digit + 1
    Endcase
  Endfor

  IsValid = m.punctuation >= 2 ;
    And m.digit >= 2 ;
    And m.upCase >= 2 And m.lowCase >= 2

  If m.IsValid
    Local Array laUsed[1]
    Select Count(*) ;
      FROM passwordStore ;
      WHERE MyCryptor.Decrypt(passwordField) == m.tcPassword ;
      INTO Array laUsed
    IsValid = (laUsed = 0)
  Endif

  Return m.IsValid
endproc
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform