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 static SecureString GenerateRandomSeed()
        {
            char[] chars = new char[27];
            chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ9".ToCharArray();
            byte[] data = new byte[1];
            using (RNGCryptoServiceProvider crypto = new RNGCryptoServiceProvider())
            {
                crypto.GetNonZeroBytes(data);
                data = new byte[81];
                crypto.GetNonZeroBytes(data);
            }
            StringBuilder result = new StringBuilder(81);

            foreach (byte b in data)
            {
                result.Append(chars[b % (chars.Length)]);
            }
            return(SecureStringController.ConvertToSecureString(result.ToString()));
        }
Ejemplo n.º 3
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");
            }
        }