private void GunaButton1_Click(object sender, EventArgs e) { if (Internals.checklogin() == true) { login(); } else { gunaLabel4.Text = "Registering... This may take a while"; register(); } }
public static bool log = false;/// <summary> /// this will be true if the user is logged in /// </summary> public Login() { InitializeComponent(); Debug.WriteLine("login started"); if (Internals.checklogin() == false) { Properties.Settings.Default.Reset(); gunaLabel3.Text = "Register"; } else { Internals.initialize(); } }
public MainForm()//we completly finished login/encryption/decryption/validation/etc etc i forgot, before i work on the main stuff im going to see what features other password vaults have { InitializeComponent(); Internals.initialize(); MessageBox.Show($"Welcome back, {Internals.grabusername()}!");//display username if (File.Exists(@"Vault\accounts\accounts.csv")) { readcsv(); id = listView1.Items.Count; } else { Directory.CreateDirectory(@"Vault\accounts");; } lbltitleitems.Text = $"Logins Saved: {listView1.Items.Count}"; MessageBox.Show(Properties.Settings.Default.Key + "\n\n" + Properties.Settings.Default.InitializationVector + "\n\n" + Properties.Settings.Default.Pepper); }
public void readcsv() { using (var reader = new StreamReader(@"Vault\accounts\accounts.csv")) using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture)) { var records = csv.GetRecords <Items>().ToList(); foreach (var person in records) { var items = new ListViewItem(person.ID.ToString());//create a list of items to add essentally items.SubItems.Add(Encoding.ASCII.GetString(Internals.decryptdata(Convert.FromBase64String(person.website), Internals.key, Internals.iv))); items.SubItems.Add(Encoding.ASCII.GetString(Internals.decryptdata(Convert.FromBase64String(person.username), Internals.key, Internals.iv))); items.SubItems.Add(Encoding.ASCII.GetString(Internals.decryptdata(Convert.FromBase64String(person.password), Internals.key, Internals.iv))); items.SubItems.Add(Encoding.ASCII.GetString(Internals.decryptdata(Convert.FromBase64String(person.date), Internals.key, Internals.iv))); //grab the date and time and add it listView1.Items.Add(items); //add all of the items we created } } }
private void GunaButton1_Click(object sender, EventArgs e) { // string pwd = "Click to reveal.";//dont store unencrypted password this is bool valweb = Internals.validatewebsite(txtwebs.Text.ToLower()); //they are both booleans so i could remove these to lower time and increase speed bool vallgn = Internals.validateuserandpass(txtlgn.Text); //^ bool valps = Internals.validateuserandpass(txtpassw.Text); //^^ if (valweb == true) { if (vallgn == true & valps == true) { // string json = serialize.serilizeitems(id, txtwebs.Text, txtlgn.Text, txtpassw.Text, DateTime.Now.ToString("hh:mm:ssss MM/dd/yyyy")); writecsv();// try { var items = new ListViewItem(id.ToString()); //create a list of items to add essentally items.SubItems.Add(txtwebs.Text); //add wevsute to listbox items.SubItems.Add(txtlgn.Text); //add login to listvbox items.SubItems.Add(txtpassw.Text); //add pass items.SubItems.Add(DateTime.Now.ToString("hh:mm:ssss MM/dd/yyyy")); //grab the date and time and add it listView1.Items.Add(items); //add all of the items we created } catch (Exception ex) { MessageBox.Show($"Error: {ex.Message}"); Internals.writeerro(ex.Message); } } else { MessageBox.Show("You must enter a valid login/password!"); } } else { MessageBox.Show("You must enter a valid website!"); } lbltitleitems.Text = updateitems(listView1);//update every time they click da button id++; }
public void writecsv() { try { //convert all these values to bytes so that i can encrypt it later byte[] _web = Encoding.ASCII.GetBytes(txtwebs.Text); byte[] _usr = Encoding.ASCII.GetBytes(txtlgn.Text); byte[] _lgn = Encoding.ASCII.GetBytes(txtpassw.Text); byte[] _date = Encoding.ASCII.GetBytes(DateTime.Now.ToString("hh:mm:ssss MM/dd/yyyy")); //encyrpt the bytes String _Web = Convert.ToBase64String(Internals.encryptdata(_web, Internals.key, Internals.iv)); String _Usr = Convert.ToBase64String(Internals.encryptdata(_usr, Internals.key, Internals.iv)); String _Pass = Convert.ToBase64String(Internals.encryptdata(_lgn, Internals.key, Internals.iv)); String _Date = Convert.ToBase64String(Internals.encryptdata(_date, Internals.key, Internals.iv)); CsvConfiguration csvConfig = new CsvConfiguration(CultureInfo.CurrentCulture) { HasHeaderRecord = !File.Exists(@"Vault\accounts\accounts.csv") }; var records = new List <Items> { }; records.Add(new Items { ID = id, website = _Web, username = _Usr, password = _Pass, date = _Date }); using (FileStream fileStream = new FileStream(@"Vault\accounts\accounts.csv", FileMode.Append, FileAccess.Write, FileShare.ReadWrite)) { using (var writer = new StreamWriter(fileStream)) using (var csv = new CsvWriter(writer, csvConfig)) { csv.WriteRecords(records); } } } catch (Exception ex) { MessageBox.Show("Error! Please check error lo!"); Internals.writeerro(ex.Message); } }
private void login() { if (Internals.validate(txtuser.Text) && Internals.validate(txtpass.Text))//make sure usertext and passtext is valid // i shouldve validated in internals but its too late now { if (txtuser.Text == Internals.grabusername() && Internals.hash(txtpass.Text, Internals.grabsalt()) == Internals.grabpassword()) { MessageBox.Show("Logged in!"); this.Hide(); //hide form MainForm frm = new MainForm(); //create new form main frm.Show(); //show it } else { MessageBox.Show("Please check your username/password!", "Invalid login credentials"); } } else { MessageBox.Show("Please check your username/password!", "Invalid login credentials"); } }
private void register() { if (Internals.validate(txtuser.Text) && Internals.validate(txtpass.Text)) //make sure usertext and passtext is valid // i shouldve validated in internals but its too late now { if (Internals.start(txtuser.Text, txtpass.Text) == true) //register user/pass { MessageBox.Show("Registered!"); this.Hide(); //hide form MainForm frm = new MainForm(); //create new form main frm.Show(); //show it } else { MessageBox.Show($"Welcome back, {Internals.grabusername()}!", "Welcome!"); this.Hide(); MainForm frm = new MainForm();//just in case if there is an erro frm.Show(); } } else { MessageBox.Show("Username & password must be at least 5 charcters"); }//im just gonna mess up on porpose }
private void InformationToolStripMenuItem_Click(object sender, EventArgs e) { MessageBox.Show($"Username:{Internals.grabusername()} \nVersion:0.0.0.1\nTotal Saved passwords:{listView1.Items.Count} ", "The vault", MessageBoxButtons.OK, MessageBoxIcon.Information); }