65.9K
CodeProject is changing. Read more.
Home

Generate a Random Password

emptyStarIconemptyStarIconemptyStarIconemptyStarIconemptyStarIcon

0/5 (0 vote)

Oct 11, 2013

CPOL
viewsIcon

4861

This is simple and effective method for generation of a random password Public Function GeneratePassword(ByVal PwdLength As Integer) As String   

This is simple and effective method for generation of a random password

Public Function GeneratePassword(ByVal PwdLength As Integer) As String
    Dim _allowedChars As String = "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ0123456789"
    Dim rndNum As New Random()
    Dim chars(PwdLength - 1) As Char
    Dim strLength As Integer = _allowedChars.Length
    For i As Integer = 0 To PwdLength - 1
        chars(i) = _allowedChars.Chars(CInt(Fix((_allowedChars.Length) * rndNum.NextDouble())))
    Next i
    Return New String(chars)
End Function

 

Nimish Garg
Software Developer
Indiamart Intermesh Limited, Noida

To Get Free ASP.NEt & Oracle Code Snippets
Follow: http://nimishgarg.blogspot.com