Ejemplo n.º 1
0
        //opens a dialog asking for password of selected recipent
        private void AskForRecipentPassword(DecryptionOutput decryptionOutput)
        {
            InsertPswrdWindow insertPswrdWindow =
                new InsertPswrdWindow(decryptionOutput);

            insertPswrdWindow.Show();
            insertPswrdWindow.Owner = this;
        }
Ejemplo n.º 2
0
        private DecryptionOutput GetSelectedValuesFromGUIDecryption()
        {
            //enter values from input controls to EncryptionInput object
            DecryptionInput di = new DecryptionInput(InputFileTextBoxDecryption.Text,
                                                     OutputFileTextBoxDecryption.Text,
                                                     (User)RecipentsListBoxDecryption.SelectedItem);

            DecryptionOutput decryptionOutput =
                InputHandlers.ParseDecryptionValues(di);

            return(decryptionOutput);
        }
Ejemplo n.º 3
0
        private void Worker_DoWorkDecryption(object sender, DoWorkEventArgs e)
        {
            var worker = sender as BackgroundWorker;

            worker.ReportProgress(0);

            DecryptionOutput decryptionOutput = (DecryptionOutput)e.Argument;

            Decryption decryption = new Decryption(decryptionOutput);

            decryption.Decrypt(worker);
        }
Ejemplo n.º 4
0
        public static DecryptionOutput ParseDecryptionValues(DecryptionInput ei)
        {
            bool   readingAllOK    = true;
            string outDirectory    = "";
            string decodedFileName = "";
            string errorMsg        = "";

            //retrieve input file and output file name
            string inputFilePath = ei.InputFile;

            if (string.IsNullOrEmpty(inputFilePath) ||
                !File.Exists(inputFilePath))
            {
                readingAllOK = false;
                errorMsg    += "Błędnie wybrany plik do zaszyfrowania.\n";
            }
            else
            {
                outDirectory = System.IO.Path.GetDirectoryName(inputFilePath);
            }

            string outputFileName = ei.OutputFileName;
            string outputFilePath = "";

            if (string.IsNullOrEmpty(outputFileName) ||
                (outputFileName.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0))
            {
                readingAllOK = false;
                errorMsg    += "Błędna nazwa pliku wyjściowego.\n";
            }
            else
            {
                outputFilePath  = outDirectory + "\\" + outputFileName;
                decodedFileName = outDirectory + "\\result.txt";
            }


            //retrieve selected recipent of encoded file from listbox
            User recipent = ei.Recipent;

            if (recipent == null)
            {
                readingAllOK = false;
                errorMsg    += "Brak wybranego odbiorcy pliku.\n";
            }

            //create and return an object keeping track of all read data
            DecryptionOutput decryptionOutput = new DecryptionOutput(readingAllOK,
                                                                     inputFilePath, outputFilePath, recipent, errorMsg);

            return(decryptionOutput);
        }
Ejemplo n.º 5
0
        //called by second window when user password is obtained
        //upon that decryption can be performed
        public void OnUserPasswordGiven(DecryptionOutput decryptionOutput)
        {
            // progress bar config
            BackgroundWorker worker = new BackgroundWorker();

            worker.WorkerReportsProgress = true;
            worker.RunWorkerCompleted   += Worker_RunWorkerCompletedDecryption;
            worker.DoWork          += Worker_DoWorkDecryption;
            worker.ProgressChanged += Worker_ProgressChangedDecryption;

            //start decryption
            worker.RunWorkerAsync(decryptionOutput);
        }
Ejemplo n.º 6
0
        private void DecodeButton_Click(object sender, RoutedEventArgs e)
        {
            //get values from the user (from gui)
            //todo setting global var here, watch out
            DecryptionOutput decryptionOutput =
                GetSelectedValuesFromGUIDecryption();

            bool correctInput = decryptionOutput.IsInputCorrect;

            if (correctInput)
            {
                AskForRecipentPassword(decryptionOutput);
            }
            else
            {
                MessageBoxResult result =
                    MessageBox.Show(decryptionOutput.ErrorMessage,
                                    "Błędne dane wejściowe", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
        }
Ejemplo n.º 7
0
 public Decryption(DecryptionOutput decryptionOutput)
 {
     DecryptionOutput = decryptionOutput;
 }
Ejemplo n.º 8
0
 public InsertPswrdWindow(DecryptionOutput decryptionOutput)
 {
     InitializeComponent();
     DecryptionOutput      = decryptionOutput;
     labelUserName.Content = decryptionOutput.Recipent.Email;
 }