Get Random Password
// Copyright (c) 2010
// by http://openlightgroup.net/
using System;
using System.Data;
using System.Linq;
using System.Web;
using System.Xml.Linq;
using System.Net.Mail;
using System.Text;
using System.Collections.Generic;
using System.IO;
using System.Web.Security;
namespace SilverlightDebateForum
{
public class Utility
{
#region GetRandomPassword
public string GetRandomPassword()
{
StringBuilder builder = new StringBuilder();
Random random = new Random();
int intElements = random.Next(10, 26);
for (int i = 0; i < intElements; i++)
{
int intRandomType = random.Next(0, 2);
if (intRandomType == 1)
{
char ch;
ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65)));
builder.Append(ch);
}
else
{
builder.Append(random.Next(0, 9));
}
}
return builder.ToString();
}
#endregion
}
}
Related examples in the same category