Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Threading
- Module Module1
- Dim pass As String
- Dim newPass As String
- Dim numbers As Integer
- Dim charFromPass As String
- Dim charFromPass2 As String
- Dim charFromPass3 As String
- Dim length As Integer
- Dim MinLength As Integer = 8
- Dim Valid As Integer
- Dim CapCount As Integer
- Dim LowCount As Integer
- Dim Users As Integer
- Dim UI As Char
- Dim Counter As Integer
- Sub Main()
- Console.WriteLine(" - Username and Password Storage Program - ")
- Console.WriteLine()
- Console.WriteLine(" # How many users would you like to store?")
- Do
- Console.Write(" # Users: ")
- Try
- Users = Console.ReadLine()
- Catch ex As Exception
- Console.WriteLine("Invalid Input. Please input a positive integer.")
- End Try
- Loop Until Users > 0
- Call UserName()
- End Sub
- Dim FName(Users) As String
- Dim SName(Users) As String
- Dim PassW(Users) As String
- Sub UserName()
- For index = 0 To Users - 1
- Console.Clear()
- Console.WriteLine(" # Username Input")
- Console.WriteLine()
- Console.WriteLine("Please enter the first name for user " & index & ".")
- Console.Write("Input: ")
- Dim Fname(index) As String
- FName(index) = Console.ReadLine()
- Console.WriteLine("Please enter the surname for user " & index & ".")
- Console.Write("Input: ")
- Dim Sname(index) As String
- SName(index) = Console.ReadLine()
- Next
- Call PasswordCheck()
- End Sub
- Sub PasswordCheck()
- Console.Clear()
- For index = 0 To Users - 1
- Console.WriteLine("Password Program")
- Console.WriteLine()
- Do
- Console.Write("Please Enter a New Password:> ")
- Dim PassW(index) As String
- PassW(index) = Console.ReadLine
- Console.WriteLine()
- Console.Write("Please Re-Enter Password:> ")
- newPass = Console.ReadLine
- If newPass = PassW(index) Then
- Console.Clear()
- Console.WriteLine("Thankyou - your password will now be sent for checking - please wait....")
- Console.WriteLine()
- For index2 = 1 To 12
- Console.Write(".")
- Thread.Sleep(200)
- Next
- Console.Write(" OK")
- Thread.Sleep(200)
- Console.WriteLine()
- Console.WriteLine()
- Else
- Console.WriteLine("Passwords do not match - Please Re-Enter")
- End If
- ' The benefit of using a named constant is that a user is able to modify the variable in one change much easier than searching the code for individual values.
- If PassW(index).Length >= MinLength Then
- Valid = 1
- Else
- Console.WriteLine("Password must be at least 8 characters long")
- End If
- Loop Until Valid = 1
- length = newPass.Length
- For position = 1 To length
- charFromPass = Mid(newPass, position, 1)
- If InStr("0123456789", charFromPass) > 1 Then
- numbers = numbers + 1
- End If
- Next
- For position = 1 To length
- charFromPass2 = Mid(newPass, position, 1)
- If InStr("QWERTYUIOPASDFGHJKLZXCVBNM", charFromPass2) > 1 Then
- CapCount = CapCount + 1
- End If
- Next
- For position = 1 To length
- charFromPass3 = Mid(newPass, position, 1)
- If InStr("qwertyuiopasdfghjklzxcvbnm", charFromPass3) > 1 Then
- LowCount = LowCount + 1
- End If
- Next
- If numbers = 1 Then
- Console.WriteLine("Contains a number")
- Else
- Console.WriteLine("Containts at least two numbers")
- End If
- If LowCount > 0 And CapCount > 0 And numbers >= 2 Then
- Console.WriteLine("STRONG PASSWORD")
- ElseIf LowCount > 0 And CapCount > 0 And numbers = 0 Then
- Console.WriteLine("MEDIUM PASSWORD")
- ElseIf LowCount > 0 And numbers > 0 And CapCount = 0 Then
- Console.WriteLine("MEDIUM PASSWORD")
- ElseIf numbers > 0 And CapCount > 0 And LowCount = 0 Then
- Console.WriteLine("MEDIUM PASSWORD")
- ElseIf numbers = 0 And LowCount = 0 And CapCount = 0 Then
- Console.WriteLine("WEAK PASSWORD")
- End If
- Next
- Console.WriteLine("Would you like to display all users and relevant information? (Y/N)")
- Console.WriteLine("(N will exit the program.)")
- Console.Write("Input: ")
- Do
- Try
- UI = Console.ReadLine()
- Catch ex As Exception
- Console.WriteLine("That is not a valid input. Please try again.")
- End Try
- If UI = "Y" Or UI = "y" Then
- Counter = 1
- ElseIf UI = "N" Or "n" Then
- Counter = 0
- End If
- Loop Until Counter = 1
- Select Case UI
- Case "Y"
- Call Display()
- Case "y"
- Call Display()
- Case "N"
- Console.WriteLine("Exiting...")
- Thread.Sleep(200)
- Case "n"
- Console.WriteLine("Exiting...")
- Thread.Sleep(200)
- End Select
- End Sub
- Sub Display()
- Console.Clear()
- Console.WriteLine("Stored User Data:")
- Console.WriteLine("¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯")
- Console.WriteLine()
- For index = 0 To Users - 1
- Console.WriteLine(FName(index) & " " & SName(index) & " " & PassW(index))
- Next
- Console.ReadLine()
- End Sub
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement