/// <summary> /// Loads encrypted text from a respected file (from the display setting passed) /// decrypts and parses the the information. /// </summary> /// <returns>True if parse successful, false if unsuccessful</returns> public bool LoadData() { UserInformationCollection = new List <UserInformation>(); var path = Display.Resource; string cipherText = string.Empty; using (var fileStream = File.Open(path, FileMode.OpenOrCreate, FileAccess.ReadWrite)) { using (StreamReader sr = new StreamReader(fileStream, true)) { cipherText = sr.ReadToEnd(); } } if (!string.IsNullOrEmpty(cipherText)) { Security.AES AES_SecurityPackage = new Security.AES(EncryptionKey, InitilizationVector); string plainText = AES_SecurityPackage.Decrypt(Encoding.Default.GetBytes(cipherText)); if (string.IsNullOrEmpty(plainText)) { return(false); } UserInformation info = new UserInformation(); string parsed = string.Empty; for (int i = 0; i < plainText.Length; i++) { if (plainText[i] == ' ') { info.Description = parsed; parsed = string.Empty; } else if (plainText[i] == '\r' || plainText[i] == '\n' || plainText[i].Equals(Environment.NewLine)) { if (info.Description != null) { info.Password = parsed; UserInformationCollection.Add(info); info = new UserInformation(); } parsed = string.Empty; } else if (i == plainText.Length - 1) { parsed += plainText[i]; info.Password = parsed; UserInformationCollection.Add(info); } else { parsed += plainText[i]; } } return(true); } return(false); }