我正在尝试使用点系统制作密码强度测试仪。 VB.net

时间:2017-11-06 18:04:29

标签: vb.net

代码必须根据以下条件添加和减少点数。

+5有一个大写

+5有一个小写

一位数+5

+5有这些符号之一!“$%^&()_-

-5仅包含大写

-5仅包含小写

-5仅包含数字

-5仅包含符号

我正在努力使代码每个标准添加5点而不是多次在VB.net中感谢任何帮助。抱歉忘了发布我的代码。

       points = Len(password)
    counter = 1
    While counter < Len(password) + 1
        letter = GetChar(password, counter)
        convletter = Asc(letter)

        'Ascii values for uppercase exclusive
        If 64 < convletter < 91 Then
            'Adds 5 points
            points = points + 5
            'Ascii values for lowercase letters exclusive
        ElseIf 96 < convletter < 123 Then
            'If letter is lowercase + 5 points
            points = points + 5
            'Ascii values for digits exclusive
        ElseIf 47 < convletter < 58 Then
            points = points + 5

        End If

        counter = counter + 1
    End While

    Console.WriteLine(points)
    Console.ReadLine()

我需要代码循环遍历字符串的字母,但只添加5个点而不是重复,我怎么能解决这个问题。 *对不起,我是新来的

2 个答案:

答案 0 :(得分:1)

试试这个:

<div id="result"></div>
<div id="result123"></div>

<script type="text/javascript">

     if(yourGlobalVariable==000)
     {
       console.log("call first time");

        $.ajax({
            url: 'http://localhost/nitin/test1',
            type: 'POST',
            success: function(msg) {
              $( "#result" ).empty().append( msg );
              console.log(msg);
            }
        });     
    }

    if(yourGlobalVariable==111)
    {
       console.log("call second time");
        $.ajax({
            url: 'http://localhost/nitin/test1',
            type: 'POST',
            success: function(msg) {
               $( "#result123" ).empty().append( msg );
               console.log(msg);
            }
      });
   }

答案 1 :(得分:0)

Dim UpCase As Boolean = False
Dim LowCase As Boolean = False
Dim Digit As Boolean = False
Dim Symbol As Boolean = False
Dim UpCaseOnly As Boolean = False
Dim LowCaseOnly As Boolean = False
Dim SymbolOnly As Boolean = False
Dim DigitOnly As Boolean = False
Dim Password As String = "!" & chr(34) & "/$%?&*()-_"
Dim Points As Integer = Password.Length
'check password
For Each xChar As Char In Password
    Select Case xChar
        Case "A" To "Z"
            UpCase = True
        Case "a" To "z"
            LowCase = True
        Case "0" To "9"
            Digit = True
        Case "!" To "/", "_" 'ascii 33 to 47 !"/$%?&*()- and 95 _ '
            Symbol = True
    End Select
Next
If (Symbol = True) And (UpCase = False) And (LowCase = False) And (Digit = False) Then SymbolOnly = True
If (Symbol = False) And (UpCase = True) And (LowCase = False) And (Digit = False) Then UpCaseOnly = True
If (Symbol = False) And (UpCase = False) And (LowCase = True) And (Digit = False) Then LowCaseOnly = True
If (Symbol = False) And (UpCase = False) And (LowCase = False) And (Digit = True) Then DigitOnly = True

'check for points
If SymbolOnly = True Then Points -= 5
If UpCaseOnly = True Then Points -= 5
If LowCaseOnly = True Then Points -= 5
If DigitOnly = True Then Points -= 5
If (LowCaseOnly = False) And (LowCase = True) Then Points += 5
If (UpCaseOnly = False) And (UpCase = True) Then Points += 5
If (DigitOnly = False) And (Digit = True) Then Points += 5
If (SymbolOnly = False) And (Symbol = True) Then Points += 5