- Local time
- Yesterday, 18:05
- Joined
- Feb 28, 2001
- Messages
- 30,501
As to password complexity, you can do some simple tests.
For instance, you can do something like this:
The only wrinkle in the above is that punctuation is distributed among several gaps between the digits, upper case, and lower case numbers. Note also that if you choose to disallow a punctuation characters, you would have to add a special case statement for that one character value to mark as "No Good."
For instance, you can do something like this:
Code:
Public Function PwdComplex(Pwd as String) as Boolean
Dim Constant UpperA = Asc("A")
Dim Constant UpperZ = Asc("Z")
Dim Constant LowerA = Asc("a")
Dim Constant LowerZ = Asc("z")
Dim Constant Digit0 = Asc("0")
Dim Constant Digit9 = Asc("9")
Dim Constant LowPrint = Asc("!")
Dim Constant HiPrint = Asc( "~" )
Dim LowerNum as Long
Dim UpperNum as Long
Dim DigitNum as Long
Dim PunctNum as Long
Dim NoGoodNum as Long
Dim PLen as Long
Dim PPos as Long
Dim EPwd as String
Dim EChr as String
Dim LChr as Long
DigitNum = 0
LowerNum = 0
UpperNum = 0
PunctNum = 0
NoGoodNum = 0
EPwd = Trim$( Pwd )
PLen = Len( EPwd )
For PPos = 1 to PLen
EChr = Mid$( EPwd, PPos, 1)
LChr = Asc(EChr)
Select Case LChr
Case Digit0 to Digit 0
DigitNum = DigitNum + 1
Case UpperA to UpperZ
UpperNum = UpperNum + 1
Case LowerA to LowerZ
LowerNum = LowerNum + 1
Case Is > HiPrint
NoGoodNum = NoGoodNum + 1
Case Is < LowPrint
NoGoodNum = NoGoodNum + 1
Case Else
PunctNum = PunctNum + 1
End Select
Next PPos
'{here, you would put rules such as minimum number of each category - my site requires 2 of each}
PwdComplex = ( DigitNum >= 2 ) and (PunctNum >=2 ) and (LowerNum >= 2) and (UpperNum >= 2) and NoGoodNum = 0
End Function
The only wrinkle in the above is that punctuation is distributed among several gaps between the digits, upper case, and lower case numbers. Note also that if you choose to disallow a punctuation characters, you would have to add a special case statement for that one character value to mark as "No Good."