Hi all,
I was just reading my c# book on some functions and spotted the random function, and I came up with makeing a small password generator. it very basic but seems to do the tick the code is also small anyway thought I share it with you. Hope you find it usfull comments are welcome.
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
//Random chars to pick a password from
const string iChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Random Rnd = new Random();
StringBuilder sb = new StringBuilder();
for (int x = 0; x < 10; x++)
{
//Pull out a random number
int RndNum = Rnd.Next(iChars.Length - 1);
//Build the random string.
sb.Append(iChars[RndNum]);
}
//Display random string
MessageBox.Show("Here is your random password: " + sb.ToString());
}
}
}
Umm I am not sure if this is the correct way but maybe you can fill an array and check if the item is already found if so generate a new password. I am faced with the same problum now cos I updated my password generator and will upload today some time.
Hi
This is an update of the Random Password Maker, it now has a gui so it easyer to use, you can set the length of the password to create and the number of passwords to create, You also have options to create Alpha, AlphaNumeric, or Numeric only passwords, there also a option to copy selected password to clipboard and option to save passwords. Hope you like the update.
Thanks goes to Max Peck for helping me with the random problum.
thanks for the share man this will be very useful, i am trying to make it so that the password's are generated to a list using file append text and a while(true) loop. problem is the while loop is just keep goign dn wont stop iv tryed break; with button click's ect, problem is i can click a button of the program says not responding. i know that the program is still running because my text file witch i am writing the passwords to keeps going up in size. i have been told to try using threads ect nt to sure how but im fairly new to c#.