/// <summary> /// Function to load the settings from the encrypted file. /// </summary> /// <returns>string[2] where [0] is the sort order and [1] is the user's password.</returns> private string[] loadSettings() { //Now Works! Crypter cryptic = new Crypter(); string path = "SaveData/Settings.txt"; if (File.Exists(path)) { List <string> saves = new List <string>(); string save; using (var reader = new StreamReader(File.OpenRead(path))) { while (!reader.EndOfStream) { save = reader.ReadLine(); saves.Add(cryptic.Decrypt(save)); foreach (string line in saves) { var splat = line.Split('|'); if (splat.Count() == 2) { return(splat); } else { return(new string[] { "Last", "" }); } } } } } return(new string[] { "Last", "" }); }
private void ViewContact_Load(object sender, EventArgs e) { if (CurrentContactID != -1) { //TODO Populate contact info. var currentContact = new Contact(CurrentContactID); if (currentContact.Secured) { string input = Microsoft.VisualBasic.Interaction.InputBox("You must enter a password to view this contact.", "Security"); string password = ""; //Now Works! Crypter cryptic = new Crypter(); string path = "SaveData/Settings.txt"; if (File.Exists(path)) { List <string> saves = new List <string>(); string save; var reader = new StreamReader(File.OpenRead(path)); while (!reader.EndOfStream) { save = reader.ReadLine(); saves.Add(cryptic.Decrypt(save)); foreach (string line in saves) { var splat = line.Split('|'); if (splat.Count() == 2) { //Load worked password = splat[1]; } else { //Failed } } } } if (input != password) { System.Windows.Forms.MessageBox.Show("Password was entered incorrectly, returning to main menu."); this.Close(); } } txt_FirstName.Text = currentContact.FirstName; txt_LastName.Text = currentContact.LastName; txt_HomePhone.Text = currentContact.HomePhone; txt_CellPhone.Text = currentContact.CellPhone; txt_WorkPhone.Text = currentContact.WorkPhone; txt_Email.Text = currentContact.Email; txt_Address.Text = currentContact.Address; txt_Relationship.Text = currentContact.Relation; chk_favorite.Checked = currentContact.Favorite; chk_Secure.Checked = currentContact.Secured; } else { txt_FirstName.Text = "First"; txt_LastName.Text = "Last"; } }