i am writing a passowrd generator and want to include an external .txt file for the words for the passwerds.
this is the code using strings so far:
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;
namespace PasswordGenerator{ public partial class frmPasswordGenerator : Form { public frmPasswordGenerator() { InitializeComponent(); }
private void btnGenerate_Click(object sender, EventArgs e) { txtOutput.Text = "";
int NumberOfPasswords = int.Parse(txtNumPass.Text); int PasswordLength = int.Parse(txtLength.Text);
for (int i = 0; i < NumberOfPasswords; i++) { for (int g = 0; g < PasswordLength; g++) { txtOutput.Text += GetCharacter(); } txtOutput.Text += "\r\n"; } } private string GetCharacter() {
string[] Lower = new string[4] { "dog", "badger", "monkey", "trumpet" }; string[] Upper = new string[10] { "apple", "cow", "operation", "onion", "peach", "qwerty", "wendy", "ronald", "mac", "chimney" }; string[] Number = new string[10] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" };
Random rand = new System.Random(Guid.NewGuid().GetHashCode()); int rplace = rand.Next(0, 3); int rplace2 = 0;
{ rplace = rand.Next(0, 3); } switch (rplace) { case 0: rplace2 = rand.Next(0, 4); return Lower[rplace2]; case 1: rplace2 = rand.Next(0, 10); return Upper[rplace2]; case 2: rplace2 = rand.Next(0, 10); return Number[rplace2]; default: return "";
} }
private void frmPasswordGenerator_Load(object sender, EventArgs e) {
}
private void cbLower_CheckedChanged(object sender, EventArgs e) {
} }}