Password Generator
Submitted by admin on Monday, April 29, 2013 - 00:06.
This password generator is based on the class created by Obviex. The generator can create a unique password that does not include ambiguous character. It can create alphanumeric and special character password. The password will always start with a letter.
The best part here is that you can choose if you want to include a special character or numeric value by simply adding the pre-defined constant in the array.
This can be done by using the following code:
Other values are
You may also download the complete project below.
- Dim charGroups As Char()() = New Char()() _
- { _
- PASSWORD_CHARS_NUMERIC.ToCharArray(), _
- PASSWORD_CHARS_LCASE.ToCharArray() _
- }
PASSWORD_CHARS_UCASE
and PASSWORD_CHARS_SPECIAL
.
Here’s an example code that calls the RandomPassword class.
- Imports System.Data.OleDb
- Public Class frmGenPass
- Dim cnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Data.mdb;"
- Private Sub btnGenPass_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGenPass.Click
- Dim I As Integer
- Dim strPass As String
- Dim strSQL As String
- For I = 1 To 10
- strPass = RandomPassword.Generate(6, 6)
- Try
- ListBox1.Items.Add(strPass)
- strSQL = "INSERT INTO Users ([Password]) VALUES ('" & strPass & "')"
- ExecNonQuery(strSQL)
- Catch ex As Exception
- Debug.Print(ex.Message)
- End Try
- Next
- End Sub
- 'Execute Non Query
- Public Sub ExecNonQuery(ByVal strSQL As String)
- Dim conn As OleDbConnection
- conn = New OleDbConnection
- Try
- With conn
- .ConnectionString = cnString
- .Open()
- End With
- Dim cmd As OleDbCommand = New OleDbCommand(strSQL, conn)
- cmd.ExecuteNonQuery()
- Catch ex As OleDbException
- Finally
- End Try
- End Sub
- Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
- End
- End Sub
- End Class
Add new comment
- 492 views