Secure Password Generator in Visual Basic
Submitted by Yorkiebar on Friday, May 16, 2014 - 05:16.
Introduction:
This tutorial is on how to create a simple tool in Visual Basic to generate a secure password.
Design:
For this we are simply going to add a button to begin the process and a numericupdown to specify the amount of characters needed for the password.
Button Click:
Variables:
First we want to create a Random object because this will choose which character to select next. Secondly we want an array of the different characters which can be chosen to be put in the password...
For Loop:
Next we want to iterate around a for loop for the amount of characters that are needed for the password (numericupdown's value). For each loop we want to use the Random object to choose a number lower than the size of the characters char array/single dimensional string and append it to a new string in the making, 'pw'...
Finally:
The final thing we have to do is output the password in a messagebox...
- Dim random As New Random
- Dim chars As String = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#?/!"
- Dim pw As String = Nothing
- For i As Integer = 0 to numericupdown1.Value
- pw += chars(random.Next(chars.count - 1))
- Next
- MsgBox(pw)
Add new comment
- 85 views