private void LoadUrl() { try { // Get syncInfo from file, written by GroupSync WebAPI using (var tr = new StreamReader(Path.Combine(GetFolderPath(), "OneRosterURL.txt"))) { oneRosterUrl.Text = StringCipher.decrypt(tr.ReadToEnd(), StringCipher.getKey()); } } catch (Exception) { oneRosterUrl.Text = ""; } }
private void saveUrlBtn_Click(object sender, EventArgs e) { var savePath = Path.Combine(GetFolderPath(), "OneRosterURL.txt"); try { using (TextWriter tw = new StreamWriter(savePath)) { tw.Write(StringCipher.encrypt(oneRosterUrl.Text.Trim(), StringCipher.getKey())); MessageBox.Show(@"URL Saved"); } } catch (IOException a) { // something happened? MessageBox.Show(a.Message); } }
private static IEnumerable <Credentials> getCredentialList() { try { // Get syncInfo from file, written by GroupSync WebAPI using (var tr = new StreamReader(Path.Combine(Main.GetFolderPath(), "Credentials.txt"))) { return(JsonConvert.DeserializeObject <List <Credentials> >(StringCipher.decrypt(tr.ReadToEnd(), StringCipher.getKey()))); } } catch (Exception) { return(new List <Credentials>()); } }
private void saveCredentials() { var credList = (from DataGridViewRow row in credDataView.Rows select new Credentials { alias = row.Cells[0].Value?.ToString(), key = row.Cells[1].Value?.ToString(), secret = row.Cells[2].Value?.ToString() }).ToList(); var savePath = Path.Combine(Main.GetFolderPath(), "Credentials.txt"); try { using (TextWriter tw = new StreamWriter(savePath)) { tw.Write(StringCipher.encrypt(JsonConvert.SerializeObject(credList), StringCipher.getKey())); MessageBox.Show(@"Credentials Saved"); _promptSave = false; } } catch (IOException e) { // something happened? MessageBox.Show(e.Message); } }