private void SaveButton_Click(object sender, RoutedEventArgs e) { var filePath = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "account"); var id_protected = MachineKeyProtect.Protect(idBox.Text, "id"); var pw_protected = MachineKeyProtect.Protect(passwordBox.Password, "pw"); System.IO.File.WriteAllText(filePath, id_protected + System.Environment.NewLine + pw_protected); this.Close(); }
public static bool GetSavedAccount_Password(out string password) { password = string.Empty; var filePath = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "account"); if (System.IO.File.Exists(filePath)) { var lines = System.IO.File.ReadAllLines(filePath); if (lines.Length != 2) { return(false); } password = MachineKeyProtect.Unprotect(lines[1], "pw"); if (!string.IsNullOrEmpty(password)) { return(true); } } return(false); }