示例#1
0
 private void SaveConvertedFile(object sender, RoutedEventArgs e)
 {
     if (locationField.Text.Equals(""))
     {
         MessageBox.Show("Filelocation is empty!");
         return;
     }
     if (passField.Password.Equals(""))
     {
         MessageBox.Show("Passfield is empty!");
         return;
     }
     if (!encryptionRadio.IsChecked.GetValueOrDefault()) //Decryption
     {
         CrudFile.SaveDecryptedFile(File.ReadAllBytes(locationField.Text), passField.Password);
     }
     else //Encryption
     {
         if (passField.Password.Equals(passCheckField.Password))
         {
             CrudFile.SaveEncryptedFile(File.ReadAllText(locationField.Text), passField.Password, true, false);
         }
         else
         {
             MessageBox.Show("Passwords are not same!");
         }
     }
     CleanVariables();
 }
示例#2
0
        } //Exist

        private void SaveDataToFile(object sender, RoutedEventArgs e)
        {
            if (dataContent.Text == "" || passField.Password == "")
            {
                MessageBox.Show("Text is empty!");
                CleanPassWithContext(true);
                return;
            }
            if (!encStateBool)             //Decr
            {
                if (!crypTypeStandardBool) //
                {
                    CrudFile.SaveDecryptedFile(Convert.FromBase64String(dataContent.Text), passField.Password);
                }
                else if (crypTypeStandardBool && toBitConverterResult)
                {
                    var data = GetBytes(dataContent.Text);
                    if (data == null)
                    {
                        MessageBox.Show("Can't get bytes! Incorrect input data!");
                        CleanPassWithContext(false);
                        return;
                    }
                    CrudFile.SaveDecryptedFile(data, passField.Password);
                    data = null;
                }
                else if (crypTypeStandardBool && !toBitConverterResult)
                {
                    MessageBox.Show("This mode doesn't work correct. Please, change it and try again!");
                    CleanPassWithContext(false);
                    return;
                }
                else
                {
                    MessageBox.Show("Something gone wrong...");
                }
            }
            else //Encr
            {
                if (passField.Password.Equals(passCheckField.Password))
                {
                    CrudFile.SaveEncryptedFile(dataContent.Text, passField.Password, crypTypeStandardBool, toBitConverterResult);
                }
                else
                {
                    MessageBox.Show("Passwords are not same!");
                }
            }
            MessageBox.Show("Completed!");

            dataContent.Text = "";
            CleanPassWithContext(false);
        } //Exist, Need check