internal void SaveFile(string FilePath) { if (FilePath.ToLower().EndsWith(".ctxt") == true) { ctxtFile ctxtfile = new ctxtFile(FilePath); if (ctxtfile.GetEncryption() == ctxtFile.Encryption.CryptotextEditorAES & ctxtFile.GetPassphrase(FilePath).Length < 2) { ctxtproperties ctxtp = new ctxtproperties(FilePath, true, MainForm); ctxtp.ShowDialog(); } else { ctxtfile.saveOpenedCtxt(MainForm.Document.Rtf); } MainForm.MenuItemFileProperties.Enabled = true; MainForm.mtsProperties.Enabled = true; } else { if (FilePath.ToLower().EndsWith(".txt") == true) { MainForm.Document.SaveFile(FilePath, RichTextBoxStreamType.PlainText); } else { MainForm.Document.SaveFile(FilePath, RichTextBoxStreamType.RichText); } MainForm.MenuItemFileProperties.Enabled = false; MainForm.mtsProperties.Enabled = false; } FileInfo fi = new FileInfo(FilePath); MainForm.Text = fi.Name.ToString() + " - CryptotextEditor"; Settings.CurrentFileSaved = true; Settings.CurrentFilePath = FilePath; if (Settings.LastOpenedFile != FilePath) { MainForm.MenuItemFileLastOpened.Text = fi.Name.ToString(); Settings.LastOpenedFile = FilePath; } }
private void buttonSave_Click(object sender, EventArgs e) { ctxtFile.Encryption sEnc; if (comboBoxEncryption.SelectedIndex == 0) { sEnc = ctxtFile.Encryption.TimeAES; } else if (comboBoxEncryption.SelectedIndex == 1) { sEnc = ctxtFile.Encryption.CryptotextEditorAES; } else { sEnc = ctxtFile.Encryption.Base64; } ctxtFile ctxtfile = new ctxtFile(thisFilePath); ctxtfile.encName = sEnc; ctxtfile.SaveWithRTF = checkBoxWithRTF.Checked; ctxtfile.PassPhrase = textBoxPassphrase.Text; ctxtfile.SavePassString = checkBoxSavePassInFile.Checked; ctxtfile.WriteFile(editor.Document.Rtf); System.IO.FileInfo fi = new System.IO.FileInfo(thisFilePath); editor.Text = fi.Name.ToString() + " - CryptotextEditor"; Settings.CurrentFileSaved = true; Settings.CurrentFilePath = thisFilePath; if (Settings.LastOpenedFile != thisFilePath) { editor.MenuItemFileLastOpened.Text = fi.Name.ToString(); Settings.LastOpenedFile = thisFilePath; } Settings.Save(); this.Close(); }
private void readFileProperties(string filePath) { ctxtFile cTextFile = new ctxtFile(filePath); if (cTextFile.GetEncryption() == ctxtFile.Encryption.TimeAES) { comboBoxEncryption.SelectedIndex = 0; } else if (cTextFile.GetEncryption() == ctxtFile.Encryption.CryptotextEditorAES) { comboBoxEncryption.SelectedIndex = 1; string plainPassword = ctxtFile.GetPassphrase(filePath); if (plainPassword.Length > 1) { checkBoxSavePassInFile.Checked = true; textBoxPassphrase.Text = plainPassword; } else { checkBoxSavePassInFile.Checked = false; textBoxPassphrase.Focus(); } } else { comboBoxEncryption.SelectedIndex = 2; } if (ctxtProperties.DocIsRTF(filePath) == true) { checkBoxWithRTF.Checked = true; } else { checkBoxWithRTF.Checked = false; } }
internal void AutoSave(int SaveNum) { string asFilePath; ctxtFile file; try { asFilePath = Settings.tmpPath + "\\~CryptotextEditortext32.tmp"; file = new ctxtFile(asFilePath); if (SaveNum == 0 & Settings.AutoSave == true) { file.SaveWithRTF = false; file.WriteFile(MainForm.Document.Text); } else if (SaveNum == 1) { MainForm.Document.Text = file.ReadFile(); } } catch (UnauthorizedAccessException) { MainForm.MenuItemFormatAutoSave.Checked = false; } }
internal void OpenFile(string FilePath) { if (File.Exists(FilePath)) { if (FilePath.ToLower().EndsWith(".exe") | FilePath.ToLower().EndsWith(".msi") | FilePath.ToLower().EndsWith(".deb") | FilePath.ToLower().EndsWith(".7z") | FilePath.ToLower().EndsWith(".zip") | FilePath.ToLower().EndsWith(".rar") | FilePath.ToLower().EndsWith(".bz2") | FilePath.ToLower().EndsWith(".gz") | FilePath.ToLower().EndsWith(".tar") | FilePath.ToLower().EndsWith(".xz") | FilePath.ToLower().EndsWith(".wim") | FilePath.ToLower().EndsWith(".lnk") | FilePath.ToLower().EndsWith(".dll") | FilePath.ToLower().EndsWith(".arj") | FilePath.ToLower().EndsWith(".cpio") | FilePath.ToLower().EndsWith(".io") | FilePath.ToLower().EndsWith(".lzh") | FilePath.ToLower().EndsWith(".lha") | FilePath.ToLower().EndsWith(".dmg") | FilePath.ToLower().EndsWith(".iso") | FilePath.ToLower().EndsWith(".udf") | FilePath.ToLower().EndsWith(".vhd") | FilePath.ToLower().EndsWith(".ace") | FilePath.ToLower().EndsWith(".vdi") | FilePath.ToLower().EndsWith(".mkv") | FilePath.ToLower().EndsWith(".mp4") | FilePath.ToLower().EndsWith(".mp3") | FilePath.ToLower().EndsWith(".mpg") | FilePath.ToLower().EndsWith(".webm") | FilePath.ToLower().EndsWith(".wmv") ) { ClearDocument(); HashThisFile(FilePath); } else { MainForm.Document.Clear(); FileInfo fi = new FileInfo(FilePath); MainForm.Text = fi.Name.ToString() + " - CryptotextEditor"; if (FilePath.ToLower().EndsWith(".ctxt") == true) { ctxtFile ctxtfile = new ctxtFile(FilePath); // MessageBox.Show(ctxtfile.PassPhrase); string ctxtInnerText = ctxtfile.ReadFile(); if (ctxtInnerText != null) { try { MainForm.Document.Rtf = ctxtInnerText; } catch { MainForm.Document.Text = ctxtInnerText; } if (ctxtfile.encName == ctxtFile.Encryption.CryptotextEditorAES & ctxtfile.PassPhrase.Length < 1) { if (MainForm.toolStripAES.Visible == false) { MainForm.showAesToolStrip(); } MainForm.toolStripTextBoxAESPassphrase.Focus(); } } else { ClearDocument(); } MainForm.MenuItemFileProperties.Enabled = true; MainForm.mtsProperties.Enabled = true; } else { try { MainForm.Document.LoadFile(FilePath, RichTextBoxStreamType.RichText); } catch { MainForm.Document.LoadFile(FilePath, RichTextBoxStreamType.PlainText); } MainForm.MenuItemFileProperties.Enabled = false; MainForm.mtsProperties.Enabled = false; } MainForm.Document.ClearUndo(); Settings.CurrentFileSaved = true; Settings.CurrentFilePath = FilePath; if (Settings.LastOpenedFile != FilePath) { MainForm.MenuItemFileLastOpened.Text = fi.Name.ToString(); Settings.LastOpenedFile = FilePath; } } } else { MessageBox.Show("This file was not found."); } }