private void fileDecryptButton_Click(object sender, EventArgs e) { Algorithm_Encryption.ГОСТ_28147.D32 d32; if (OutputRichTextBox.Text == "") { MessageBox.Show("Введите данные для расшифрования", "Ошибка"); } else { byte[] btFile = encrByteFile; if (byteKey.Length != 32) { MessageBox.Show("Введдите 256-битный ключ."); } else { DateTime StartTime; MyTime = 0; StartTime = DateTime.Now; TimerAlgorithm.Interval = 60000;//в милисекундах TimerAlgorithm.Enabled = true; d32 = new Algorithm_Encryption.ГОСТ_28147.D32(btFile, byteKey); decrByteFile = d32.GetDecryptFile; OutputRichTextBox.Clear(); OutputRichTextBox.Text = Encoding.Default.GetString(decrByteFile); TimerAlgorithm.Enabled = false; DateTime EndTime = DateTime.Now; ToolStripStatusLabel.Text = "Время работы алгоритма шифрования (в миллисекундах)"; SecondsToolStripStatusLabel.Text = (EndTime - StartTime).TotalMilliseconds.ToString(); } } }
private void EncButton_Click(object sender, EventArgs e) { if (InputRichTextBox.Text == "") { MessageBox.Show("Окно для ввода текста пусто"); } else if (KeyTB.TextLength < 5 || KeyTB.TextLength > 256) { MessageBox.Show("Размер ключа должен находиться в пределах от 5 до 256 символов"); } else { TimeStart(); OutputRichTextBox.Clear(); short[] key = new short[KeyTB.TextLength]; for (int i = 0; i < KeyTB.TextLength; i++) { key[i] = (short)KeyTB.Text[i]; } Algorithm_RC4.AlgorithmRC4 encoder = new Algorithm_RC4.AlgorithmRC4(key); string testString = InputRichTextBox.Text; short[] testBytes = new short[InputRichTextBox.TextLength]; for (int i = 0; i < InputRichTextBox.TextLength; i++) { testBytes[i] = (short)InputRichTextBox.Text[i]; } short[] result = encoder.Encode(testBytes, testBytes.Length); for (int i = 0; i < result.Length; i++) { OutputRichTextBox.Text += (char)result[i]; } TimeStop(); } }
private void DecButton_Click(object sender, EventArgs e) { if (OutputRichTextBox.Text == "") { MessageBox.Show("Окно для расшифровки пусто"); } else if (KeyTB.TextLength < 5 || KeyTB.TextLength > 256) { MessageBox.Show("Размер ключа должен находиться в пределах от 5 до 256 символов"); } else { TimeStart(); short[] result = new short[OutputRichTextBox.TextLength]; for (int i = 0; i < OutputRichTextBox.TextLength; i++) { result[i] = (short)OutputRichTextBox.Text[i]; } short[] key = new short[KeyTB.TextLength]; for (int i = 0; i < KeyTB.TextLength; i++) { key[i] = (short)KeyTB.Text[i]; } Algorithm_RC4.AlgorithmRC4 decoder = new Algorithm_RC4.AlgorithmRC4(key); short[] decryptedBytes = decoder.Decode(result, result.Length); OutputRichTextBox.Clear(); for (int i = 0; i < decryptedBytes.Length; i++) { OutputRichTextBox.Text += (char)decryptedBytes[i]; } TimeStop(); } }
public MainWindow() { InitializeComponent(); // Initialize messageQueue and Assign it to Snack bar's MessageQueue var messageQueue = new SnackbarMessageQueue(TimeSpan.FromSeconds(2)); Snackbar.MessageQueue = messageQueue; // Initialize CiphersComboBox CiphersComboBox.ItemsSource = CiphersList.Instance; CiphersComboBox.DisplayMemberPath = "DisplayName"; // Initialize NewCipherDialog NewCipherDialog.Context = this; // Disable Actions EnableActions(false); // Clear initial block from RichTextBoxes InputRichTextBox.Clear(); OutputRichTextBox.Clear(); // Check for updates CheckForUpdates(); }
private void DecButton_Click(object sender, EventArgs e) { if (NCloseTB.Text == "" || DCloseTB.Text == "") { MessageBox.Show("Для зашифровки сообщения введите открытый ключ.", "Ошибка"); return; } else if (!CheckKey(NCloseTB.Text) || !CheckKey(DCloseTB.Text)) { MessageBox.Show("Открытый ключ содержит некорректные символы.", "Ошибка"); return; } else if (OutputRichTextBox.Text == "") { MessageBox.Show("Окно для расшифровки пусто", "Ошибка"); return; } else { TimeStart(); Algorithm_RSA.AlgorithmRSA rsa = new Algorithm_RSA.AlgorithmRSA(); OutputRichTextBox.Clear(); OutputRichTextBox.Text = rsa.Decrypt(enc, D, n); TimerAlgorithm.Enabled = false; TimeStop(); } }
private void ExportAudioButton_Click(object sender, RoutedEventArgs e) { var saveFileDialog = new SaveFileDialog { FileName = "MorseCode - " + AudioSpeedComboBox.Text, DefaultExt = ".wav", Filter = "Waveform Audio File|*.wav" }; if (saveFileDialog.ShowDialog() != true) { return; } var text = OutputRichTextBox.GetText(); var speed = AudioSpeedComboBox.SelectedIndex; var fileName = saveFileDialog.FileName; MorseAudioGenerator.Generate(fileName, text, CharsDelimiter, WordsDelimiter, speed); var content = $"{saveFileDialog.SafeFileName} is Saved!"; var arguments = $"/select, \"{fileName}\""; void Action() => Process.Start("explorer.exe", arguments); Snackbar.MessageQueue.Enqueue(content, "Open", Action); }
private void InputRichTextBox_OnSelectionChanged(object sender, RoutedEventArgs e) { if (MirrorToggleButton.IsChecked == false) { return; } OutputRichTextBox.ClearFormatting(); if (InputRichTextBox.Selection.IsEmpty || OutputRichTextBox.IsEmpty() || _containKeys) { return; } var inputStartPointer = InputRichTextBox.GetStart(); var outputStartPointer = OutputRichTextBox.GetStart(); var selectionStartPointer = InputRichTextBox.Selection.Start; var selectedText = InputRichTextBox.Selection.Text; var precedingText = new TextRange(inputStartPointer, selectionStartPointer).Text; var encodedSelectedText = _selectedCipher.Encode(selectedText, CharsDelimiter, WordsDelimiter); var encodedPrecedingText = _selectedCipher.Encode(precedingText, CharsDelimiter, WordsDelimiter); var highlightStartPointer = outputStartPointer.GetPositionAtOffset(encodedPrecedingText.Length + 2); var highlightEndPointer = highlightStartPointer?.GetPositionAtOffset(encodedSelectedText.Length + 2); var highlightTextRange = new TextRange(highlightStartPointer, highlightEndPointer); var brush = _isLight ? Brushes.Yellow : Brushes.DarkMagenta; highlightTextRange.ApplyPropertyValue(TextElement.BackgroundProperty, brush); }
private void EncButton_Click(object sender, EventArgs e) { if (NOpenTB.Text == "" || EOpenTB.Text == "") { MessageBox.Show("Для зашифровки сообщения введите открытый ключ.", "Ошибка"); return; } else if (!CheckKey(NOpenTB.Text) || !CheckKey(EOpenTB.Text)) { MessageBox.Show("Открытый ключ содержит некорректные символы.", "Ошибка"); return; } else if (InputRichTextBox.Text == "") { MessageBox.Show("Окно для ввода текста пусто", "Ошибка!"); return; } else { TimeStart(); Algorithm_RSA.AlgorithmRSA rsa = new Algorithm_RSA.AlgorithmRSA(); string input = InputRichTextBox.Text; byte[] Enc = rsa.Encrypt(input, E, n); enc = Enc; OutputRichTextBox.Clear(); for (int i = 0; i < enc.Length; i++) { OutputRichTextBox.Text += Enc[i]; } TimeStop(); } }
private void ShowKeyButton_Click(object sender, RoutedEventArgs e) { var keys = _selectedCipher.GetKeysMapping(); OutputRichTextBox.SetText(keys); _containKeys = true; // Used in mirror selection }
private void Encode() { var text = InputRichTextBox.GetText(); var encodedText = _selectedCipher.Encode(text, CharsDelimiter, WordsDelimiter); OutputRichTextBox.SetText(encodedText); }
/// <summary> /// Нажатие кнопки "стрелочка" - трансформация /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TransformStartButton_Click(object sender, EventArgs e) { Debug.WriteLine("TransformStartButton clicked"); try { if (allRules == null) { Debug.WriteLine("allRules was null"); hash = RulesInputRichTextBox.Text.GetHashCode(); Debug.WriteLine("got hash: " + hash.ToString()); allRules = transformationComponent.TransformToRules(RulesInputRichTextBox.Text, true); Debug.WriteLine("parsed rules succesfully"); } var text = transformationComponent.Transform(InputTestRichTextBox.Text, allRules, SourceLangTextBox.Text, TargetLangTextBox.Text); OutputRichTextBox.Text = text; Debug.WriteLine("parsed model succesfully"); Debug.WriteLine("----------Result------------"); Debug.WriteLine(text); Debug.WriteLine("----------------------------"); } catch (Exception ex) { Debug.WriteLine(ex); OutputRichTextBox.AppendException(ex); } }
private void OutputRichMessage(String date, String id, String message) { if (OutputRichTextBox == null) { return; } Paragraph paragraph = new Paragraph(); Run dateEntry = new Run(date); Run idEntry = new Run(id); Run messageEntry = new Run(message); TextRange dateRange = new TextRange(dateEntry.ContentStart, dateEntry.ContentEnd); dateRange.ApplyPropertyValue(TextElement.ForegroundProperty, System.Windows.Media.Brushes.GreenYellow); TextRange idRange = new TextRange(idEntry.ContentStart, idEntry.ContentEnd); idRange.ApplyPropertyValue(TextElement.ForegroundProperty, System.Windows.Media.Brushes.Cyan); TextRange messageRange = new TextRange(messageEntry.ContentStart, messageEntry.ContentEnd); messageRange.ApplyPropertyValue(TextElement.ForegroundProperty, System.Windows.Media.Brushes.DarkOrange); paragraph.Inlines.AddRange(new Run[] { dateEntry, idEntry, messageEntry }); OutputRichTextBox.Document.Blocks.Add(paragraph); OutputRichTextBox.ScrollToEnd(); }
private void DisplayCurrentRound(Round round) { SpinsTextblock.Text = round.Spin.ToString(); TextBox1.Text = round.WinningNumber.ToString(); GoalTextBlock.Text = Goal.ToString("0.00"); MoneyTextBlock.Text = round.Money.ToString("0.00"); BetUnitTextBlock.Text = round.BetUnit.ToString("0.00"); if (round.Spin >= SessionStart) { OutputRichTextBox.Document.Blocks.Clear(); OutputRichTextBox.Document.TextAlignment = TextAlignment.Center; if (round.ExpectedNumbers != null) { OutputRichTextBox.AppendText($"\nPlace {round.BetUnit} on the {round.ExpectedNumbers.Count} expected numbers: " + $"\n\n" + String.Join(", ", round.ExpectedNumbers)); } } else { OutputRichTextBox.Document.Blocks.Clear(); OutputRichTextBox.Document.TextAlignment = TextAlignment.Center; OutputRichTextBox.AppendText($"\nExpected numbers: \n\n ???"); } }
//выполнение программы private async void RunButton_Click(object sender, EventArgs e) { OutputRichTextBox.Clear(); VariablesRichTextBox.Clear(); StackTraceRichTextBox.Clear(); try { using (Executer = new Executer(SourceCodeFastColoredTextBox.Text)) { using (TokenSource = new CancellationTokenSource()) { StopButton.Enabled = true; RunButton.Enabled = false; //нужен для остановки выполнения программы CancellationToken cancelToken = TokenSource.Token; //запускаем выполнение программы в отдельной задаче OutputRichTextBox.Text += await Task.Run(() => Executer.Execute(cancelToken), cancelToken); StopButton.Enabled = false; RunButton.Enabled = true; } TokenSource = null; } } catch (Exception exp) { OutputRichTextBox.Text += exp.Message; } }
//// Footer Event Handlers //// private void ToggleThemeButton_Click(object sender, RoutedEventArgs e) { var mode = _isLight ? BaseTheme.Dark : BaseTheme.Light; ThemeAssist.SetTheme(this, mode); _isLight ^= true; OutputRichTextBox.ClearFormatting(); }
/// <summary> /// Кнопка "Парсинг текста правил" /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ParseRulesButton_Click(object sender, EventArgs e) { try { int gothash = RulesInputRichTextBox.Text.GetHashCode(); if (hash != gothash) { Debug.WriteLineIf(allRules == null, "allRules was null"); Debug.WriteLineIf(hash != RulesInputRichTextBox.Text.GetHashCode(), "hash was:" + hash + " got:" + gothash); hash = gothash; Debug.WriteLine("new hash:" + hash); allRules = transformationComponent.TransformToRules(RulesInputRichTextBox.Text, true); Debug.WriteLine("rules parsed succesful"); AutoCompleteStringCollection names = new AutoCompleteStringCollection(); names.AddRange(allRules.Languages.ToArray()); SourceLangTextBox.AutoCompleteCustomSource = names; SourceLangTextBox.AutoCompleteMode = AutoCompleteMode.Suggest; SourceLangTextBox.AutoCompleteSource = AutoCompleteSource.CustomSource; TargetLangTextBox.AutoCompleteCustomSource = names; TargetLangTextBox.AutoCompleteMode = AutoCompleteMode.Suggest; TargetLangTextBox.AutoCompleteSource = AutoCompleteSource.CustomSource; OutputRichTextBox.StartTimestamp(); OutputRichTextBox.AppendText(DateTime.Now.ToString() + ": Правила запарсены успешно\n", System.Drawing.Color.Black); OutputRichTextBox.EndTimestamp(); } else { Debug.WriteLine("rules where ready and same hash"); if (MessageBox.Show( "Похоже, входная строка не изменилась. Вы уверены, что хотите повторить парсинг?", "", MessageBoxButtons.YesNo) == DialogResult.Yes) { Debug.WriteLine("got yes"); hash = RulesInputRichTextBox.Text.GetHashCode(); Debug.WriteLine("new hash:" + hash); allRules = transformationComponent.TransformToRules(RulesInputRichTextBox.Text, true); Debug.WriteLine("rules parsed succesful"); } else { Debug.WriteLine("got not yes"); } } } catch (Exception ex) { Debug.WriteLine(ex); OutputRichTextBox.AppendException(ex); } }
private void EncButton_Click(object sender, EventArgs e) { if (InputRichTextBox.Text == "") { MessageBox.Show("Введите данные для шифрования", "Ошибка"); } else { if (!CheckInput(InputRichTextBox.Text)) { if (MessageBox.Show("В процессе шифровки может произойти потеря части текста.\n(Число символов должно быть кратно 16)\nПрервать шифровку?", "Предупреждение!", MessageBoxButtons.YesNo) == DialogResult.Yes) { return; } } if (!CheckKey(KeyTB.Text)) { MessageBox.Show("Неверный формат ключа", "Ошибка"); return; } TimeStart(); byteKey = Encoding.Default.GetBytes(KeyTB.Text); E24 e24 = new E24(); string[] inputMsg = new string[InputRichTextBox.Text.Length / 16]; int j = 0; for (int i = 0; i < inputMsg.Length; i++) { inputMsg[i] = InputRichTextBox.Text.Substring(j, 16); j += 16; } OutputRichTextBox.Clear(); for (int i = 0; i < inputMsg.Length; i++) { byte[] btFile = Encoding.Default.GetBytes(inputMsg[i]); GenerationKeys newKey = new GenerationKeys(); if (!newKey.SetKey(byteKey)) { MessageBox.Show("Error key!!!"); return; } encrByteFile = e24.Encrypt(btFile, newKey.eKey); char[] eeee = Encoding.Default.GetChars(encrByteFile); foreach (var f in eeee) { OutputRichTextBox.Text += f.ToString(); } } TimeStop(); } }
private void ToggleFillButton_Click(object sender, RoutedEventArgs e) { if (_isFilled) { OutputRichTextBox.Replace(SolidShapes, OutlineShapes); } else { OutputRichTextBox.Replace(OutlineShapes, SolidShapes); } _isFilled ^= true; }
private void CancelBtn_Click(object sender, RoutedEventArgs e) { pendingProcessKill = true; if (KillProcesses()) { Paragraph paragraph = new Paragraph() { Foreground = Brushes.Magenta }; paragraph.Inlines.Add(new Run("KILLED ALL PROCESSES")); OutputFlowDocument.Blocks.Add(paragraph); OutputRichTextBox.ScrollToEnd(); } }
private void keyGenerateButton_Click(object sender, EventArgs e) { KeyTB.Clear(); OutputRichTextBox.Clear(); byte[] GenerateKey = new byte[32]; Random RandomNumb = new Random(); for (int i = 0; i < GenerateKey.Length; i++) { GenerateKey[i] = (byte)RandomNumb.Next(0, 255); KeyTB.Text += (char)GenerateKey[i]; } byteKey = GenerateKey; }
private void OutputRichMessageWithImage(String date, String id, Byte[] imageBytes) { if (OutputRichTextBox == null) { return; } Paragraph paragraph = new Paragraph(); Run dateEntry = new Run(date); Run idEntry = new Run(id); TextRange dateRange = new TextRange(dateEntry.ContentStart, dateEntry.ContentEnd); dateRange.ApplyPropertyValue(TextElement.ForegroundProperty, System.Windows.Media.Brushes.GreenYellow); TextRange idRange = new TextRange(idEntry.ContentStart, idEntry.ContentEnd); idRange.ApplyPropertyValue(TextElement.ForegroundProperty, System.Windows.Media.Brushes.Cyan); BitmapImage bitmap = new BitmapImage(); using (var stream = new MemoryStream(imageBytes)) { stream.Seek(0, SeekOrigin.Begin); bitmap.CreateOptions = BitmapCreateOptions.PreservePixelFormat; bitmap.CacheOption = BitmapCacheOption.OnLoad; bitmap.BeginInit(); bitmap.StreamSource = stream; bitmap.EndInit(); } Image image = new Image { Source = bitmap, Width = 20 }; Figure imageFigure = new Figure() { Width = new FigureLength(100) }; imageFigure.Blocks.Add(new BlockUIContainer(image)); paragraph.Inlines.AddRange(new Run[] { dateEntry, idEntry }); OutputRichTextBox.Document.Blocks.Add(paragraph); OutputRichTextBox.ScrollToEnd(); }
private void fileEncryptButton_Click(object sender, EventArgs e) { Algorithm_Encryption.ГОСТ_28147.E32 e32; if (InputRichTextBox.Text == "") { MessageBox.Show("Введите данные для шифрования", "Ошибка"); } else { if (!CheckInput(InputRichTextBox.Text)) { if (MessageBox.Show("В процессе шифровки может произойти потеря части текста.\n(Число символов должно быть кратно 8)\nПрервать шифровку?", "Предупреждение!", MessageBoxButtons.YesNo) == DialogResult.Yes) { return; } } byte[] btFile = Encoding.Default.GetBytes(InputRichTextBox.Text); if ((byteKey == null) || (byteKey.Length != 32)) { MessageBox.Show("Введдите 256-битный ключ."); } else { DateTime StartTime; MyTime = 0; StartTime = DateTime.Now; TimerAlgorithm.Interval = 60000;//в милисекундах TimerAlgorithm.Enabled = true; e32 = new Algorithm_Encryption.ГОСТ_28147.E32(btFile, byteKey); encrByteFile = e32.GetEncryptFile; OutputRichTextBox.Clear(); OutputRichTextBox.Text = Encoding.Default.GetString(encrByteFile); TimerAlgorithm.Enabled = false; DateTime EndTime = DateTime.Now; ToolStripStatusLabel.Text = "Время работы алгоритма шифрования (в миллисекундах)"; SecondsToolStripStatusLabel.Text = (EndTime - StartTime).TotalMilliseconds.ToString(); } } }
private void OutputRichInfo(String message) { if (OutputRichTextBox == null) { return; } Paragraph paragraph = new Paragraph(); Run entry = new Run(message); paragraph.Inlines.Add(entry); TextRange entryRange = new TextRange(entry.ContentStart, entry.ContentEnd); entryRange.ApplyPropertyValue(TextElement.ForegroundProperty, System.Windows.Media.Brushes.Teal); entryRange.ApplyPropertyValue(TextElement.FontStyleProperty, FontStyles.Italic); OutputRichTextBox.Document.Blocks.Add(paragraph); OutputRichTextBox.ScrollToEnd(); }
private void EncryptAppsInSelectedPath() { // find all appx files string directoryPath = UriTextBox.Text; var allDirectoryFilePaths = Directory.GetFiles(directoryPath, "*.appx", SearchOption.AllDirectories); // foreach (var filePath in allDirectoryFilePaths) { //foreach file generate a key for encryption var fileGuidString = Directory.GetParent(filePath).Name; var encryptionKey = FileEncryptor.GenerateEncryptionKey(fileGuidString.ToLower()); // encrypt and save file with generatedKey OutputRichTextBox.AppendText($"Start encrypting file {fileGuidString} ..."); FileEncryptor.EncryptFile(filePath, encryptionKey); OutputRichTextBox.AppendText($"file {fileGuidString} encrypted" + Environment.NewLine); } }
//запуск пошагового выполнения программы private void StepRunButton_Click(object sender, EventArgs e) { try { OutputRichTextBox.Clear(); SourceCodeFastColoredTextBox.Enabled = false; StepRunButton.Enabled = false; RunButton.Enabled = false; StopButton.Enabled = true; Executer = new Executer(SourceCodeFastColoredTextBox.Text); StepIntoButton.Enabled = true; StepOverButton.Enabled = true; //выделяем первую строку в main ChangeLineColor(Executer.FindMain().LineNo - 1); } catch (Exception exp) { OutputRichTextBox.Text += exp.Message; } }
private void ResetUI() { List <TextBox> textBoxes = new List <TextBox> { TextBox1, TextBox2, TextBox3, TextBox4, TextBox5, TextBox6, TextBox7, TextBox8, TextBox9, TextBox10, TextBox11, TextBox12 }; foreach (var tb in textBoxes) { tb.Clear(); } SpinsTextblock.Text = "0"; GoalTextBlock.Text = Goal.ToString("0.00"); MoneyTextBlock.Text = StartingMoney.ToString("0.00"); BetUnitTextBlock.Text = StartingBetUnit.ToString("0.00"); OutputRichTextBox.Document.Blocks.Clear(); OutputRichTextBox.Document.TextAlignment = TextAlignment.Center; OutputRichTextBox.AppendText($"\nExpected numbers: \n\n ???"); }
private void DecButton_Click(object sender, EventArgs e) { if (OutputRichTextBox.Text == "") { MessageBox.Show("Введите данные для расшифрования", "Ошибка"); } else if (KeyTB.TextLength != 32) { MessageBox.Show("Длина ключа должна быть равна 32 символам"); } else { TimeStart(); Algorithm_AES.AlgorithmAES aes = new Algorithm_AES.AlgorithmAES(); byte[] key = new byte[KeyTB.TextLength]; for (int i = 0; i < KeyTB.TextLength; i++) { key[i] = (byte)bufkey[i]; } byte[] Buffer = aes.Decrypt(resbuf, key, IV); OutputRichTextBox.Clear(); for (int i = 0; i < Buffer.Length; i++) { if (buf[i] - 1024 > 0) { OutputRichTextBox.Text += (char)(Buffer[i] + 1024); } else { OutputRichTextBox.Text += (char)Buffer[i]; } } TimeStop(); } }
private void EncButton_Click(object sender, EventArgs e) { if (InputRichTextBox.TextLength == 0) { MessageBox.Show("Введите данные для шифрования", "Ошибка"); } else if (KeyTB.TextLength != 32) { MessageBox.Show("Длина ключа должна быть равна 32 символам"); } else if (InputRichTextBox.TextLength % 16 != 0) { MessageBox.Show("Длина текста должна быть кратна 16"); } else { TimeStart(); OutputRichTextBox.Clear(); Algorithm_AES.AlgorithmAES aes = new Algorithm_AES.AlgorithmAES(); byte[] Buffer; buf = new short[InputRichTextBox.TextLength]; byte[] res = new byte[InputRichTextBox.TextLength]; for (short i = 0; i < InputRichTextBox.TextLength; i++) { buf[i] = (short)InputRichTextBox.Text[i]; } //массив buf необходимый для равботы с символами русского алфавита for (short i = 0; i < InputRichTextBox.TextLength; i++) { if (buf[i] - 1024 > 0) { res[i] = (byte)(buf[i] - 1024); } else { res[i] = (byte)buf[i]; } } bufkey = new short[KeyTB.TextLength]; byte[] key = new byte[KeyTB.TextLength]; for (int i = 0; i < KeyTB.TextLength; i++) { bufkey[i] = (short)KeyTB.Text[i]; } for (short i = 0; i < KeyTB.TextLength; i++) { if (bufkey[i] - 1024 > 0) { key[i] = (byte)(bufkey[i] - 1024); } else { key[i] = (byte)bufkey[i]; } } Buffer = aes.Encrypt(res, key, IV); resbuf = Buffer;//запоминаем массив при необходимости расшифрования for (int i = 0; i < Buffer.Length; i++) { OutputRichTextBox.Text += (char)Buffer[i]; } TimeStop(); } }
private void KeyTB_TextChanged(object sender, EventArgs e) { OutputRichTextBox.Clear(); }
private void CloseKeyLabel_TextChanged(object sender, EventArgs e) { OutputRichTextBox.Clear(); }