예제 #1
0
        private void saveAs()
        {
            // flush previous password
            password = string.Empty;
            // open file dialog
            SaveFileDialog dlgSave = new SaveFileDialog
            {
                Filter   = "Encrypted text file (*.tenc)|*.tenc",
                Title    = "Select file name",
                FileName = "newfile.tenc"
            };

            if (dlgSave.ShowDialog() == DialogResult.OK)
            {
                filename = dlgSave.FileName;
                PasswordEntry dlgPassword = new PasswordEntry();
                if (dlgPassword.ShowDialog() == DialogResult.OK)
                {
                    password = dlgPassword.Password.Text;

                    // encryp
                    save();
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Load the file with stored filename
        /// </summary>
        private void loadFile()
        {
            PasswordEntry dlgPassword = new PasswordEntry();

            if (dlgPassword.ShowDialog() == DialogResult.OK)
            {
                password = dlgPassword.Password.Text;

                // decrypt
                txtContent.Text            = Encryption.Decrypt(filename, password);
                isChanged                  = false;
                txtContent.SelectionStart  = 0;
                txtContent.SelectionLength = 0;
            }
        }