public void Cryptanalysis() { try { UiServices.SetBusyState(); Paragraph paragraph = new Paragraph(); paragraph.Inlines.Add(new Bold(new Underline(new Run("** " + Languages.buttonCryptanalysis + " **\r\n")))); paragraph.Inlines.Add(new Bold(new Run(Languages.labelCiphertext))); paragraph.Inlines.Add(" " + Cipher + "\r\n"); Message = MerkleHellman.Cryptanalysis(cipher, paragraph); if (History.Document.Blocks.FirstBlock != null) { History.Document.Blocks.InsertBefore(History.Document.Blocks.FirstBlock, paragraph); } else { History.Document.Blocks.Add(paragraph); } NotifyPropertyChanged("Message"); } catch (Exception) { MessageBox.Show(Languages.errorNoSolutionFound, Languages.error, MessageBoxButton.OK, MessageBoxImage.Error); } NotifyPropertyChanged("Message"); }
public void Encrypt() { UiServices.SetBusyState(); Cipher = MerkleHellman.Encrypt(Message).ToString(); Paragraph paragraph = new Paragraph(); paragraph.Inlines.Add(new Bold(new Underline(new Run("** " + Languages.buttonEncrypt + " **\r\n")))); paragraph.Inlines.Add(new Bold(new Run(Languages.labelPlainText))); paragraph.Inlines.Add(" " + Message + "\r\n"); paragraph.Inlines.Add(new Bold(new Run(Languages.labelCiphertext))); paragraph.Inlines.Add(" " + Cipher + "\r\n"); if (History.Document.Blocks.FirstBlock != null) { History.Document.Blocks.InsertBefore(History.Document.Blocks.FirstBlock, paragraph); } else { History.Document.Blocks.Add(paragraph); } NotifyPropertyChanged("Cipher"); }