private void saveAsToolStripMenuItem_Click(object sender, EventArgs e) { var setPasswordDialog = new FormSetPassword(); if (_currentFileSystemDrive == null) { MessageBox.Show("Nothing to save!"); return; } var saveFileDialog = new SaveFileDialog { Filter = "FileSystemImage files (*.fsi)|*.fsi" }; if (saveFileDialog.ShowDialog() == DialogResult.OK) { _currentFileName = saveFileDialog.FileName; } else { return; } if (_currentFileName != null && setPasswordDialog.ShowDialog(this) == DialogResult.OK) { string password = setPasswordDialog.VerifiedPassword; SaveFileSystemImageToFile(_currentFileSystemDrive, _currentFileName, password); Log.Debug("Successfuly Saved file: {FileName}", saveFileDialog.FileName); } MemoryHandler.RunGarbageCollect(); }
public void SetPassWord() { FormSetPassword f = new FormSetPassword(); DialogResult result = f.ShowDialog(); if (result == DialogResult.OK) { Password = f.Password; } ShowKey(); }
private void chkPasswordProtectBookmarks_MouseUp(object sender, MouseEventArgs e) { if (chkPasswordProtectBookmarks.Checked) { using (var formSetPassword = new FormSetPassword()) { if (formSetPassword.ShowDialog(this) == DialogResult.OK) { if (formSetPassword.VerifiedPassword == null) { chkPasswordProtectBookmarks.Checked = false; return; } _applicationSettingsService.Settings.EnablePasswordProtectBookmarks(formSetPassword.VerifiedPassword); _applicationSettingsService.SaveSettings(); _bookmarkService.SaveBookmarks(); } else { chkPasswordProtectBookmarks.Checked = false; } } } else { using ( var formgetPassword = new FormGetPassword { PasswordDerivedString = _applicationSettingsService.Settings.PasswordDerivedString }) { if (formgetPassword.ShowDialog() == DialogResult.OK && formgetPassword.PasswordVerified) { _applicationSettingsService.Settings.DisablePasswordProtectBookmarks(); _applicationSettingsService.SaveSettings(); // Check bookmark status //if (BookmarkService.Instance.BookmarkManager == null) // BookmarkService.Instance.Dispose(); } else { chkPasswordProtectBookmarks.Checked = true; } } } }
private void changePasswordToolStripMenuItem_Click(object sender, EventArgs e) { var frmsetPassword = new FormSetPassword { Text = "Choose a new password" }; if (frmsetPassword.ShowDialog(this) != DialogResult.OK) { return; } string password = frmsetPassword.VerifiedPassword; _passwordStorage.Set(PwdKey, password); _memoStorageService.SaveTabPageCollection(_tabPageDataCollection, password); _appSettingsService.Settings.PasswordDerivedString = GeneralConverters.GeneratePasswordDerivedString(_appSettingsService.Settings.ApplicationSaltValue + password + _appSettingsService.Settings.ApplicationSaltValue); _appSettingsService.SaveSettings(); UpdateApplicationState(); }
private void createNewDatabaseToolStripMenuItem_Click(object sender, EventArgs e) { if ( MessageBox.Show(this, "Do you want to create a new Memo database? Doing so will overwrite any existing stored database under this account.", "Create new database?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK) { return; } var frmSetPassword = new FormSetPassword { Text = "Choose password" }; if (frmSetPassword.ShowDialog(this) != DialogResult.OK) { return; } string password = frmSetPassword.VerifiedPassword; if (string.IsNullOrEmpty(password)) { MessageBox.Show(this, "Password can not be empty!", Resources.FormMain__ErrorText, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } _passwordStorage.Set(PwdKey, password); _logicManager.CreateNewDatabase(); _appSettingsService.Settings.PasswordDerivedString = GeneralConverters.GeneratePasswordDerivedString(_appSettingsService.Settings.ApplicationSaltValue + password + _appSettingsService.Settings.ApplicationSaltValue); _appSettingsService.SaveSettings(); InitializeTabControls(); _applicationState.DatabaseLoaded = true; _applicationState.DatabaseExists = true; UpdateApplicationState(); }
private void SaveToSharedFolderToolStripMenuItem_Click(object sender, EventArgs e) { if (!_appSettingsService.Settings.UseSharedSyncFolder) { MessageBox.Show(Resources.FormMain_saveToSharedFolderMenuDisabled, Resources.FormMain__Could_not_save, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (string.IsNullOrWhiteSpace(_appSettingsService.Settings.SyncFolderPath) || !Directory.Exists(_appSettingsService.Settings.SyncFolderPath)) { MessageBox.Show(Resources.FormMain_saveToSharedFoldrMenuInvalidPath, Resources.FormMain__Could_not_save, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } var formSetPassword = new FormSetPassword(); if (formSetPassword.ShowDialog(this) != DialogResult.OK) { formSetPassword.Dispose(); return; } string password = formSetPassword.VerifiedPassword; _passwordStorage.Set("SharedFolderPassword", password); formSetPassword.Dispose(); bool result = _logicManager.SaveToSharedFolder(); if (result) { MessageBox.Show("Database successfully saved to sync folder", Resources.FormMain__Database_Saved, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Failed to save database to sync folder path", Resources.FormMain__Could_not_save, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void saveToSharedFolderToolStripMenuItem_Click(object sender, EventArgs e) { if (!_appSettingsService.Settings.UseSharedSyncFolder) { MessageBox.Show(Resources.FormMain_saveToSharedFolderMenuDisabled, Resources.FormMain__Could_not_save, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (string.IsNullOrWhiteSpace(_appSettingsService.Settings.SyncFolderPath) || !Directory.Exists(_appSettingsService.Settings.SyncFolderPath)) { MessageBox.Show(Resources.FormMain_saveToSharedFoldrMenuInvalidPath, Resources.FormMain__Could_not_save, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } var formSetPassword = new FormSetPassword(); if (formSetPassword.ShowDialog(this) != DialogResult.OK) { return; } string password = formSetPassword.VerifiedPassword; _tabPageDataCollection.ActiveTabIndex = tabControlNotepad.SelectedIndex; bool result = _memoStorageService.SaveTabPageCollection(_tabPageDataCollection, password, true); if (result) { MessageBox.Show("Database successfully saved to sync folder", Resources.FormMain__Database_Saved, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Failed to save database to sync folder path", Resources.FormMain__Could_not_save, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static CodeSnippetCollectionOld ReadCollectionLegacy2(string filename, SecureString password, PasswordHelper passwordHelper, FormCodeLibrary mainform, out bool succes) { string usbKeyId = null; succes = true; string _fileData = string.Empty; SecureString _usbKeyPassword = null; FileContainer _container = new FileContainer(); try { _fileData = File.ReadAllText(filename, Encoding.Default); _container = Utils.FromJson <FileContainer>(_fileData); usbKeyId = _container.UsbKeyId; } catch { succes = false; return(null); } if (_container.Encrypted) { if (!string.IsNullOrEmpty(_container.UsbKeyId)) { bool _canceled; usbKeyId = _container.UsbKeyId; byte[] _key = passwordHelper.GetUsbKey(_container.UsbKeyId, false, out _canceled); if (_canceled) { succes = false; usbKeyId = null; return(null); } _usbKeyPassword = StringCipher.ToSecureString(Utils.ByteArrayToString(_key)); CodeSnippetCollectionOld _result1 = TryDecrypt(_container.Data, _usbKeyPassword, out succes); if (succes) { passwordHelper.Password = null; passwordHelper.UsbKeyId = usbKeyId; passwordHelper.ShowKey(); return(_result1); } else { MessageBox.Show(mainform, $"Could not open file {filename}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); passwordHelper.Password = null; passwordHelper.UsbKeyId = null; passwordHelper.ShowKey(); } } // Decrypt with given password. if (password == null) { goto setPassword; } retryPassword: CodeSnippetCollectionOld _result = TryDecrypt(_container.Data, password, out succes); if (succes) { passwordHelper.Password = password; passwordHelper.UsbKeyId = null; passwordHelper.ShowKey(); return(_result); } setPassword: FormSetPassword _formSet = new FormSetPassword(); DialogResult _dg = _formSet.ShowDialog(); if (_dg == DialogResult.OK) { password = _formSet.Password; goto retryPassword; } else { succes = false; return(null); } } else { try { CodeSnippetCollectionOld _collection = Utils.FromJson <CodeSnippetCollectionOld>(Utils.FromBase64(_container.Data)); _collection.FromBase64(); passwordHelper.Password = null; passwordHelper.UsbKeyId = null; passwordHelper.ShowKey(); succes = true; return(_collection); } catch { succes = false; return(null); } } }