New to programing and its a user/password generator. I want to have the first 4 letters in every name from the left textbox and the result should be 4 uppercase letters (i) same 4 uppercase letter / password generated
ex:
Adair Ewing
Zorro Irving
(Pusching generatbutton)
(Result)
ADAI0ASAI / dkfnwkef
ZOOR1ZOOR / woeknfwe
My code:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void buttonGenerat_Click(object sender, EventArgs e)
{
char[] radbytning = new char[]{'\r', '\n'};
string[] name = textBoxLeft.Text.Split(radbytning, StringSplitOptions.RemoveEmptyEntries);
string result = "";
for (int i = 0; i <name.Length; i++)
{
result += string.Format("{0}{1}{0} / {2}\r\n", name[i].Substring(0, 4), i, GeneratPassword());
}
textBoxRight.Text = result;
}
private static string GeneratPassword()
{
string result = "";
String tecken = "abcdefghijklmnopqrstuvxyzåäö1234567890ABCDEFGHIJKLMNOPQRSTUVXYZÅÄÖ";
Random random = new Random();
for(int i = 0; i< 8; i++)
{
result += tecken[random.Next(tecken.Length)].ToString();
System.Threading.Thread.Sleep(10);
}
return result;
}
public string FirstLetterToUpper(string)
{
if (str == null)
return null;
if (str.Length > 1)
return char.ToUpper(str[0]) + str.Substring(1);
return str;
}
}
}