Temp Password (Generate Random password).

Bageshkumarbagi
Posted by Bageshkumarbagi under C# category on | Points: 40 | Views : 742
private void button1_Click(object sender, EventArgs e)
{
StringBuilder TempPassword = 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)));
TempPassword.Append(ch);
}
else
{
TempPassword.Append(random.Next(0, 9));
}
}


MessageBox.Show("Password "+TempPassword.ToString());
}

Comments or Responses

Login to post response