Это то, что вы обычно делаете при создании или изменении пароля.Обычно я использую что-то вроде следующей функции для проверки сложности пароля:
'PasswordComplexityRegex is a string value I get from a database at login,
'if it is not present then a default one will be use.
Dim PasswordComplexityRegex as String
'MinimunPasswordLenght is also a number stored in a database if not present
'it will use a default, in this case 12.
Public Function validatePassword(ByVal pass As String) As Boolean
Dim pattern As String = "[~`!@#$%^&*()-_=+';:,./<>?]"
If Not (String.IsNullOrEmpty(PasswordComplexityRegex)) Then
pattern = PasswordComplexityRegex
End If
Dim patternRegex As Match = Regex.Match(pass, pattern)
'In this case it checks that the length of the password is >= to 12
If (IsDBNull(MinimunPasswordLenght) Or MinimunPasswordLenght = 0) Then
MinimunPasswordLenght = 12
End If
Return (patternRegex.Success And pass.Length >= MinimunPasswordLenght)
End Function
Это ключ, который вы всегда проверяете Regex, он немного сложнее, чем некоторые думают.
Теперь используйте эту функцию, чтобы подтвердить свой пароль и определить, продолжается или нет.Что-то вроде:
If Not validatePassword(txtNewPassword.Text) Then
MsgBox("Password need to be...", vbCritical, "Password not in compliance...")
End If
Вы должны разрешить все символы, включая Unicode, и не должны ограничивать длину более строго, например, если MySQL ограничивает ее.Вы должны поощрять комбинацию букв, цифр, заглавных букв и т. Д.
Nandostyle