private void ProcessCipher(OperationType OpType) { DTStart = DateTime.Now; exeptionOccured = false; ManualStop.Reset(); try { if (OpType == OperationType.DecryptFile) { if (!File.Exists(EncryptFileTBox.Text)) { throw new Exception("File Does Not Exist: " + EncryptFileTBox.Text); } if (ComboBoxIndex == 0) { DesProvider.Decrypt(EncryptFileTBox.Text, DecryptFileTBox.Text, KeyTBox.Text); } else { AesProvider.Decrypt(EncryptFileTBox.Text, DecryptFileTBox.Text, KeyTBox.Text); } } else if (OpType == OperationType.EncryptFile) { if (!File.Exists(InputFileTBox.Text)) { throw new Exception("File Does Not Exist: " + InputFileTBox.Text); } if (ComboBoxIndex == 0) { DesProvider.Encrypt(InputFileTBox.Text, EncryptFileTBox.Text, KeyTBox.Text); } else { AesProvider.Encrypt(InputFileTBox.Text, EncryptFileTBox.Text, KeyTBox.Text); } } else if (OpType == OperationType.EncryptText) { if (ComboBoxIndex == 0) { byte[] EnBytesBuffer = DesProvider.Encrypt(Encoding.Unicode.GetBytes(InputTextTBox.Text), KeyTBox.Text); Update_EncryptedText(Convert.ToBase64String(EnBytesBuffer)); } else { byte[] EnBytesBuffer = AesProvider.Encrypt(Encoding.Unicode.GetBytes(InputTextTBox.Text), KeyTBox.Text); Update_EncryptedText(Convert.ToBase64String(EnBytesBuffer)); } } else if (OpType == OperationType.DecryptText) { if (ComboBoxIndex == 0) { byte[] EnBytesBuffer = Convert.FromBase64String(EncryptTextTBox.Text); Update_DecryptedText(Encoding.Unicode.GetString (DesProvider.Decrypt(EnBytesBuffer, KeyTBox.Text))); } else { byte[] EnBytesBuffer = Convert.FromBase64String(EncryptTextTBox.Text); Update_DecryptedText(Encoding.Unicode.GetString (AesProvider.Decrypt(EnBytesBuffer, KeyTBox.Text))); } } } catch (Exception e) { exeptionOccured = true; MessageBox.Show("Error: " + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void ProcessCipher(OperationType OpType) { DTStart = DateTime.Now; exeptionOccured = false; ManualStop.Reset(); try { if (OpType == OperationType.DecryptFile) { if (!File.Exists(VIHOD.Text)) { throw new Exception("Файл не найден по этому пути: " + VIHOD.Text); } if (ComboBoxIndex == 0) { DesProvider.Decrypt(VIHOD.Text, RASHIFR.Text, KEY.Text); } else { AesProvider.Decrypt(VIHOD.Text, RASHIFR.Text, KEY.Text); } } else if (OpType == OperationType.EncryptFile) { if (!File.Exists(VHOD.Text)) { throw new Exception("Файл не найден: " + VHOD.Text); } if (ComboBoxIndex == 0) { DesProvider.Encrypt(VHOD.Text, VIHOD.Text, KEY.Text); } else { AesProvider.Encrypt(VHOD.Text, VIHOD.Text, KEY.Text); } } else if (OpType == OperationType.DecryptText) { if (ComboBoxIndex == 0) { } else { } } else if (OpType == OperationType.EncryptText) { if (ComboBoxIndex == 0) { } else { } } } catch (Exception e) { exeptionOccured = true; MessageBox.Show("Ошибка: " + e.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }