Videos | Podcasts

Generating Unique Random Passwords
AzamSharp
Published Date: 7/15/2005 9:55:54 PM
Views: 3735

Abstract:
Most of the web application consists of login pages which authenticate the user based on username and password. For the registoration purposes you might need to create a random password and email the password to the user and than the user has to use that password to log to the website. In this article we will see how we can create a random password.


Introduction:

Sometimes we need to generate random passwords for users. In this small article we will see two techniques that will generate unique passwords.

Using GUID:

The first method of Generating unique password is by using the System.Guid class.

System.Guid.NewGuid();

Making custom method to Generate Unique Passwords:

If you want to make your own custom method that generates random passwords than you can use the method below:

string alphabets = "abcdefghijklmnopqrstuvwxyz";
string numbers = "01234567890123456789012345";
StringBuilder password = new StringBuilder();
Random r = new Random();
for(int j=0; j<=20;j++)
{
for(int i=0;i<=5;i++)
{
password.Append(alphabets[r.Next(alphabets.Length)]);
password.Append(numbers[r.Next(numbers.Length)]);
}
Response.Write(password.ToString());
password.Remove(0,password.Length);

}

The above method will generate passwords which will be the combination of alphabets and numbers.

I hope you like this article, happy coding !




Did you like this article?
kick it on DotNetKicks.com Submit
Similar Articles

CSS Sprites Merging Images to Achieve Better Performance

Why Page Event’s not Work:

Caputurig Back Button Event &amp; Force The Page To Load From Server:

Dynamic Graphics in ASP.Net 2.0

Creating Rounded Corners Using Only CSS

Enter Comment/Feedback

 
 
 
 
 

Comments/Feedbacks