Menu

Password generation algorithm

Virus_Tester
  1. Create an empty class in VB 2008 Express or newer
  2. Delete all contents
  3. Paste the following code inside it:

Public Class PasswordGenerator
'Password generation.
Public Shared Function Generate(ByVal minLength As Integer, ByVal maxLength As Integer) As String
Dim charset As String = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
Dim r As New Random()
Dim lenPass As Integer = r.Next(minLength, maxLength)
Dim str As String = String.Empty

    For i As Integer = 0 To lenPass - 1
        str += charset(r.Next(0, charset.Length))
    Next

    Return str
End Function

End Class


Related

Wiki: Home