Exemplo n.º 1
0
        private void Call_Password_Window(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = FileDialog.CreateDefaultDialog(false);

            if (openFileDialog.ShowDialog() == true)
            {
                store_path = openFileDialog.FileName;
                try
                {
                    CryptoFile          cryptoFile          = CryptoProtocol.Read(store_path);
                    PasswordEnterWindow passwordEnterWindow = new PasswordEnterWindow(cryptoFile);
                    if (passwordEnterWindow.ShowDialog() == true)
                    {
                        Window window = new MainWindow(passwordEnterWindow.Password, passwordEnterWindow.Items, store_path);
                        window.Show();
                        this.Close();
                        return;
                    }
                }
                catch (FileFormatException exp)
                {
                    string file_isnot_store_string = (string)Application.Current.FindResource("file_isnot_store_string");
                    MessageBox.Show(file_isnot_store_string, file_isnot_store_string, MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
Exemplo n.º 2
0
        public void storeData()
        {
            Crypter       crypter = new Crypter(MasterPassword.Password);
            StringBuilder str     = new StringBuilder();

            foreach (ServiceLoginPassword slp in items)
            {
                str.Append($"{slp.ServiceName} : {slp.Login} : {slp.Password.Password}\n");
            }
            byte[]     encrypted  = crypter.Encrypt(str.ToString());
            byte[]     salty      = UsefulTools.ComputeSaltySHA256(Encoding.UTF8.GetBytes(str.ToString()), crypter.Salt);
            CryptoFile cryptoFile = new CryptoFile(encrypted, salty, crypter.IV, crypter.Salt);

            CryptoProtocol.Save(cryptoFile, store_path);
        }
Exemplo n.º 3
0
        private void Call_Empty_Store_Window(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = FileDialog.CreateDefaultDialog(true);

            if (openFileDialog.ShowDialog() == true)
            {
                store_path = openFileDialog.FileName;
                EmptyStoreWindow emptyStoreWindow = new EmptyStoreWindow();
                if (emptyStoreWindow.ShowDialog() == true)
                {
                    Crypter    crypter    = new Crypter(emptyStoreWindow.Password.Password);
                    byte[]     encrypted  = crypter.Encrypt("");
                    byte[]     salty      = UsefulTools.ComputeSaltySHA256(Encoding.UTF8.GetBytes(""), crypter.Salt);
                    CryptoFile cryptoFile = new CryptoFile(encrypted, salty, crypter.IV, crypter.Salt);
                    CryptoProtocol.Save(cryptoFile, store_path);
                    Window window = new MainWindow(emptyStoreWindow.Password, new List <ServiceLoginPassword>(), store_path);
                    window.Show();
                    this.Close();
                    return;
                }
            }
        }