Example #1
0
        private void WczytajTekstZaszyfrowany_Click(object sender, RoutedEventArgs e)
        {
            Encoding enc = Encoding.GetEncoding("Windows-1250");

            try
            {
                OpenFileDialog openFileDialog1 = new OpenFileDialog
                {
                    Title            = "Wybierz plik",
                    Filter           = "Text files (*.txt)|*.txt|All files (*.*)|*.*",
                    FilterIndex      = 1,
                    RestoreDirectory = true
                };
                if (openFileDialog1.ShowDialog() == true)
                {
                    using (StreamReader sr = new StreamReader(openFileDialog1.FileName, enc))
                    {
                        String line = sr.ReadToEnd();
                        TekstZaszyfrowanyTB.Clear();
                        TekstZaszyfrowanyTB.Text = line;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Nie udało się wczytać tekstu");
            }
        }
Example #2
0
 private void SzyfrujTekstButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (TekstJawnyTB.Text == string.Empty)
         {
             throw new Exception();
         }
         TekstZaszyfrowanyTB.Clear();
         foreach (char letter in TekstJawnyTB.Text)
         {
             int        code = letter;
             BigInteger m    = code;
             TekstZaszyfrowanyTB.Text += Encrypt(private_key_wczytanyA, m).ToString() + "/";
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Wystapil błąd podczas szyfrowania");
     }
 }