Esempio n. 1
0
        private void readEncryptedText( )
        {
            string encryptText;
            string password = tboxTopLeft2.Text;

            cleanTextBoxes();

            using (StreamReader sr = File.OpenText(textFilePath)) {
                encryptText = sr.ReadToEnd();
            }

            try {
                string outputText = Protector.Dectypt(encryptText, password);
                tbTopRight.Text = $"Decrypted text from file {new FileInfo(textFilePath).Name}: \n" +
                                  $"{outputText}";
            } catch (CryptographicException ex) {
                MessageBox.Show($"Wrong password\n" +
                                $"{ex.Message}");
                return;
            } catch (Exception ex) {
                MessageBox.Show($"{ex.GetType().Name} says: \n" +
                                $"{ex.Message}");
                return;
            }
        }