segunda-feira, 29 de agosto de 2011

on


Function GetRandomPassword(ByVal length As Integer) As String
        Static rand As New Random
        Dim password As New System.Text.StringBuilder(length)

        For i As Integer = 1 To length
            Dim charIndex As Integer

            Do
                charIndex = rand.Next(48, 123)
            Loop Until (charIndex >= 48 AndAlso charIndex <= 57) OrElse (charIndex _
            >= 65 AndAlso charIndex <= 90) OrElse (charIndex >= 97 AndAlso _
            charIndex <= 122)

            password.Append(Convert.ToChar(charIndex))
        Next
        Return password.ToString()
    End Function


0 comentários:

Postar um comentário