Ejemplo n.º 1
0
        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            if (((currentVault == null) || (currentVault == "")) && (vaultData.Count > 0))
            {
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.Filter = "Iota Vault File (*.IVF)|*.IVF";
                if (saveFileDialog.ShowDialog() == true)
                {
                    currentVault = saveFileDialog.FileName;
                }
            }

            //if key doenst exist, ask for one.
            if (cryptKey == null)
            {
                CryptKeyDialog popup = new CryptKeyDialog();
                popup.ShowDialog();
                cryptKey = SecureStringController.ConvertToSecureString(popup.CryptKey);
            }

            //store file to disk
            if (currentVault != null && cryptKey != null)
            {
                JsonSerialization.WriteToJsonFile <ObservableCollection <IotaSeed> >(cryptKey, currentVault, vaultData);
                vaultData.Clear();
                cryptKey.Clear();
            }

            //Clean gui and memory

            currentVault = null;
            cryptKey     = null;
        }
Ejemplo n.º 2
0
        private void BtnOpen_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.Filter = "Iota Vault File (*.IVF)|*.IVF";
                if (openFileDialog.ShowDialog() == true)
                {
                    //ask for key to decrypt vault
                    currentVault = openFileDialog.FileName;
                    CryptKeyDialog popup = new CryptKeyDialog();
                    popup.ShowDialog();
                    cryptKey = SecureStringController.ConvertToSecureString(popup.CryptKey);

                    //decrypt vault and load data
                    LoadVaultData(JsonSerialization.ReadFromJsonFile <ObservableCollection <IotaSeed> >(cryptKey, currentVault));
                }
            }
            catch
            {
                MessageBox.Show("Failure: Wrong password or wrong file");
            }
        }