Generate Randon Passwords




Generate Randon Passwords To generate a random password in asp.net, please follow the below:

First, you need to create a string which includes all the characters that you want to be available for use in your random password, like below:
Dim strCharacters as String = "1234567890abcdefghijklmnopqrstuvwxyz"
Then you need to create an empy string to hold the random password, like below:
Dim strPassword as String = ""
Create a new random function, like below:
Dim r as New Random()
Create an integer string to allow you to determine how long your random password will be (where is says 8, replace this with a length of your choice):
Dim i as Integer
For i = 1 to 8
Then use the below code to randomly generate each character of the password and move to the next after done:
strPassword += strCharacters.Substring(r.Next(strCharacters.Length), 1)
Next
It should then look like below and you can use the strPassword string how you like.
Dim strCharacters as String = "1234567890abcdefghijklmnopqrstuvwxyz"
Dim strPassword as String = ""
Dim r as New Random()
Dim i as Integer
For i = 1 to 8
strPassword += strCharacters.Substring(r.Next(strCharacters.Length), 1)
Next


No one has said that they like article yet, be the first and click here (0)
Send a link to this page via email Send a link to this page