diff --git a/EncryptionPage/EncryptionPage.xaml.cs b/EncryptionPage/EncryptionPage.xaml.cs index b1387eb..6031ce3 100644 --- a/EncryptionPage/EncryptionPage.xaml.cs +++ b/EncryptionPage/EncryptionPage.xaml.cs @@ -73,7 +73,7 @@ public EncryptionPage() private void EncryptButton_Click(object sender, RoutedEventArgs e) { - byte[] inputBytes = Encoding.ASCII.GetBytes(InputTextBox.Text); + byte[] inputBytes = Encoding.Default.GetBytes(InputTextBox.Text); EncryptedMessage = Utils.Encrypt(inputBytes, E, N); InputBinTextBox.Text = Utils.ToString(inputBytes); diff --git a/KeyGeneratorPage/KeyGeneratorPage.xaml.cs b/KeyGeneratorPage/KeyGeneratorPage.xaml.cs index bff9690..ec7b2ee 100644 --- a/KeyGeneratorPage/KeyGeneratorPage.xaml.cs +++ b/KeyGeneratorPage/KeyGeneratorPage.xaml.cs @@ -171,14 +171,10 @@ private void GenerateButton_Click(object sender, RoutedEventArgs e) where prime < Totient && GCD(prime, Totient) == 1 select prime; - E = ee.ElementAt(rand.Next(ee.Count())); + E = (ee.Count() > 0) ? ee.ElementAt(rand.Next(ee.Count())) : 0; // 3. Находим d. D = modInverse(E, Totient); - - // Проверка. - Debug.Assert(GCD(E, Totient) == 1); - Debug.Assert((E * D) % Totient == 1); } } }