Click here to Skip to main content
13,190,404 members (49,978 online)
Click here to Skip to main content
Add your own
alternative version

Stats

2.5K views
1 bookmarked
Posted 11 Oct 2013

Generate a Random Password

, 11 Oct 2013
Rate this:
Please Sign up or sign in to vote.
This is simple and effective method for generation of a random password Public Function GeneratePassword(ByVal PwdLength As Integer) As String   

Editorial Note

This articles was originally at wiki.asp.net but has now been given a new home on CodeProject. Editing rights for this article has been set at Bronze or above, so please go in and edit and update this article to keep it fresh and relevant.

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

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

ASP.NET Community
United States United States
This member doesn't quite have enough reputation to be able to display their biography and homepage.
Group type: Collaborative Group

764 members


You may also be interested in...

Comments and Discussions

 
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171016.2 | Last Updated 11 Oct 2013
Article Copyright 2013 by ASP.NET Community
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid